bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20723: 24.4; narrow-to-line


From: Drew Adams
Subject: bug#20723: 24.4; narrow-to-line
Date: Tue, 2 Jun 2015 11:14:54 -0700 (PDT)

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]