unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Ed Avis <eda@waniasset.com>, 20723@debbugs.gnu.org
Subject: bug#20723: 24.4; narrow-to-line
Date: Tue, 2 Jun 2015 11:14:54 -0700 (PDT)	[thread overview]
Message-ID: <c9db5f26-858f-48df-937a-7bc755ee99b6@default> (raw)
In-Reply-To: <loom.20150602T185507-311@post.gmane.org>

> It would be handy to have M-x narrow-to-line to narrow the buffer to
> the line point is currently on.

(defun narrow-to-line (&optional arg)
  "Narrow to the text of the current line.
A numeric prefix arg means move forward (backward if negative) that
many lines, thus narrowing to a line other than the one point was
originally in."
  (interactive "P")
  (setq arg  (if arg (prefix-numeric-value arg) 0))
  (let ((inhibit-field-motion  t))
    (save-excursion
      (forward-line arg)
      (narrow-to-region (line-beginning-position) (line-end-position)))))

(defun mark-line (&optional arg)
  "Put mark at end of line, point at beginning.
A numeric prefix arg means move forward (backward if negative) that
many lines, thus marking a line other than the one point was
originally in."
  (interactive "P")
  (setq arg  (if arg (prefix-numeric-value arg) 0))
  (let ((inhibit-field-motion  t))
    (forward-line arg)
    (push-mark nil t t)
    (goto-char (line-end-position))))

The problem is what keys, if any, to bind them to by default.

Here are some existing commands that are similar:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html
http://www.gnu.org/software/emacs/manual/html_node/emacs/Marking-Objects.html





  reply	other threads:[~2015-06-02 18:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 16:55 bug#20723: 24.4; narrow-to-line Ed Avis
2015-06-02 18:14 ` Drew Adams [this message]
2015-06-02 18:22   ` Ed Avis
2015-06-02 19:35     ` Drew Adams
2019-11-06  2:05   ` Stefan Kangas
2019-11-06 14:06     ` Drew Adams
2019-11-06 14:14       ` Stefan Kangas
2022-01-29 17:05     ` Lars Ingebrigtsen
2015-06-02 18:32 ` Nicolas Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9db5f26-858f-48df-937a-7bc755ee99b6@default \
    --to=drew.adams@oracle.com \
    --cc=20723@debbugs.gnu.org \
    --cc=eda@waniasset.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).