GNU bug report logs -
#20723
24.4; narrow-to-line
Previous Next
Reported by: Ed Avis <eda <at> waniasset.com>
Date: Tue, 2 Jun 2015 17:01:03 UTC
Severity: wishlist
Tags: wontfix
Found in version 24.4
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20723 in the body.
You can then email your comments to 20723 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Tue, 02 Jun 2015 17:01:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ed Avis <eda <at> waniasset.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 02 Jun 2015 17:01:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
It would be handy to have M-x narrow-to-line to narrow the buffer to the
line point is currently on.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Tue, 02 Jun 2015 18:16:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 20723 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Tue, 02 Jun 2015 18:24:01 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
Thanks. I was imagining that narrow-to-line would not be bound to any key
by default. After all, even narrow-to-region comes with a warning that it is
for experts only.
--
Ed Avis <eda <at> waniasset.com>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Tue, 02 Jun 2015 18:33:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 20723 <at> debbugs.gnu.org (full text, mbox):
Ed Avis <eda <at> waniasset.com> writes:
> It would be handy to have M-x narrow-to-line to narrow the buffer to the
> line point is currently on.
I'll give my own experience : I wanted a similar command and first wrote
a naive command along the lines of :
(narrow-to-region (point-at-bol)
(save-excursion
(forward-line 1)
(point)))
but then, when widening the view, the window-start is usually modified
and I found this annoying. What I now have in my .emacs is what follows.
It keeps track of window-start and resets it when widening. Not very
clean code, but it worked good enough for me until now.
(defvar-local yf/narrow-to-line--state nil)
(defun yf/narrow-to-line ()
(interactive)
(setq yf/narrow-to-line--state
(list (selected-window) (window-start)))
(narrow-to-region (point-at-bol)
(save-excursion
(forward-line 1)
(point)))
(add-hook 'post-command-hook #'yf/unnarrow-to-line nil t))
(defun yf/unnarrow-to-line ()
(when (and yf/narrow-to-line--state
(not (buffer-narrowed-p)))
(apply #'set-window-start yf/narrow-to-line--state)
(setq yf/narrow-to-line--state nil)
(remove-hook 'post-command-hook #'yf/unnarrow-to-line t)))
(bind-key "l" 'yf/narrow-to-line narrow-map)
FWIW, totally unrelated, but I also have the following :
(defun yf/narrow-to-window-view (printmsg)
(interactive "p")
(narrow-to-region (window-start)
(save-excursion
(goto-char (window-end nil t))
(when (not (pos-visible-in-window-p))
;; Line is not fully visible.
(forward-visible-line -1))
(point)))
(when printmsg
(message "Narrowed to visible portion of buffer in current
window.")))
(bind-key "v" 'yf/narrow-to-window-view narrow-map)
--
Nico
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Tue, 02 Jun 2015 19:36:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 20723 <at> debbugs.gnu.org (full text, mbox):
> Thanks. I was imagining that narrow-to-line would not be bound to
> any key by default. After all, even narrow-to-region comes with a warning
> that it is for experts only.
`narrow-to-region' is not for experts only. It is disabled by default
because the thought is that if you don't expect it then you could get
confused, especially if you invoked it accidentally (e.g., by key).
But it nevertheless has a key binding by default.
I don't expect that `mark-line' is very useful. But I can see
someone wanting to use something like `narrow-to-line' (especially
with very long lines).
(Of course, `C-a C-SPC C-e C-x n' does the same thing, except for
keeping the cursor where it was.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Wed, 06 Nov 2019 02:06:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 20723 <at> debbugs.gnu.org (full text, mbox):
Drew Adams <drew.adams <at> oracle.com> writes:
>> 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))))
I think the proposal to add these commands make sense, since there
seems to exist a user demand. Would anyone object to including the
above commands in Emacs?
> The problem is what keys, if any, to bind them to by default.
I'd suggest that we bind narrow-to-line to 'C-x n l', and leave
mark-line unbound by default for now.
> 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
Best regards,
Stefan Kangas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Wed, 06 Nov 2019 14:09:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 20723 <at> debbugs.gnu.org (full text, mbox):
> >> It would be handy to have M-x narrow-to-line to narrow the buffer to
> >> the line point is currently on.
>
> I think the proposal to add these commands make sense, since there
> seems to exist a user demand. Would anyone object to including the
> above commands in Emacs?
>
> > The problem is what keys, if any, to bind them to by default.
>
> I'd suggest that we bind narrow-to-line to 'C-x n l', and leave
> mark-line unbound by default for now.
I agree now with Ed Avis that we should _not_ bind
either command to a key by default. Anyone who
uses them can bind them to keys.
These commands are not super-useful. There is no
reason to sacrifice default keys to them. It's
good to have such commands, but default keys
should be defined only when we know there's a lot
of clamor for them. ;-)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Wed, 06 Nov 2019 14:16:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 20723 <at> debbugs.gnu.org (full text, mbox):
Drew Adams <drew.adams <at> oracle.com> writes:
>> I'd suggest that we bind narrow-to-line to 'C-x n l', and leave
>> mark-line unbound by default for now.
>
> I agree now with Ed Avis that we should _not_ bind
> either command to a key by default. Anyone who
> uses them can bind them to keys.
>
> These commands are not super-useful. There is no
> reason to sacrifice default keys to them. It's
> good to have such commands, but default keys
> should be defined only when we know there's a lot
> of clamor for them. ;-)
That's fine by me.
Best regards,
Stefan Kangas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20723
; Package
emacs
.
(Sat, 29 Jan 2022 17:07:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 20723 <at> debbugs.gnu.org (full text, mbox):
Stefan Kangas <stefan <at> marxist.se> writes:
> I think the proposal to add these commands make sense, since there
> seems to exist a user demand. Would anyone object to including the
> above commands in Emacs?
In my opinion, they aren't generally useful enough either as commands
(it's easier to just use the normal point movement and narrowing
commands) or in code (narrowing to a line in code isn't very common), so
I don't think it's worth adding these to Emacs, and I'm therefore
closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) wontfix.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 29 Jan 2022 17:07:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
20723 <at> debbugs.gnu.org and Ed Avis <eda <at> waniasset.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 29 Jan 2022 17:07:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 27 Feb 2022 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 51 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.