unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#434: Minor Enhancement: Toggle narrowing/widen a function region and all
@ 2008-06-17  5:53 Kazuo YAGI
  2012-04-11 12:12 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Kazuo YAGI @ 2008-06-17  5:53 UTC (permalink / raw)
  To: bug-gnu-emacs

I'd like to suggest a minor enhancement below.

This is to let you toggle narrowing/widen a function region and all
when editing a source code.

This works with C-s, M-%. M-x replace-string, M-x occur, etc ...

I think it make us easy to search/replace a word within a function.
And it is for not to jump over a function if you want to edit it only.

If you will, would you comment about this minor enhancement and tell me
which *.el is suitable for adding it?

Thanks for reading,
- Kazuo

;;; In GNU Emacs 22.1.1 (i686-pc-linux-gnu)
;;;  of 2008-05-09 on milia
;;; Windowing system distributor `The X.Org Foundation', version 11.0.10400090

;;; This is to let you toggle narrowing/widen a function region and all
;;; when editing a source code.

(defvar toggle-narrowing-function-and-all-p nil)

(defun toggle-narrowing-function-and-all ()
  (setq toggle-narrowing-function-and-all-p (not toggle-narrowing-function-and-all-p)))

(defun toggle-narrowing-function ()
  (interactive)
  (toggle-narrowing-function-and-all)
  (save-excursion
    (if toggle-narrowing-function-and-all-p
        (progn
          (next-line)
          (beginning-of-defun)
          (let ((beg)(end))
            (setq beg (point))
            (end-of-defun)
            (setq end (point))
            (narrow-to-region beg end)
            (count-lines-region beg end)))
      (widen))))








^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#434: Minor Enhancement: Toggle narrowing/widen a function region and all
  2008-06-17  5:53 bug#434: Minor Enhancement: Toggle narrowing/widen a function region and all Kazuo YAGI
@ 2012-04-11 12:12 ` Lars Magne Ingebrigtsen
  2012-04-11 17:55   ` bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-11 12:12 UTC (permalink / raw)
  To: Kazuo YAGI; +Cc: 434

Kazuo YAGI <kyagi@miraclelinux.com> writes:

> This is to let you toggle narrowing/widen a function region and all
> when editing a source code.
>
> This works with C-s, M-%. M-x replace-string, M-x occur, etc ...
>
> I think it make us easy to search/replace a word within a function.
> And it is for not to jump over a function if you want to edit it only.

I think it's an interesting idea.  Narrowing to the current function to
search around in it (especially when refactoring) is something that I
often do "manually", so having a handy keystroke for it would be nice, I
think.

`C-x n f', for instance, to toggle narrowing to the current function.

Opinions?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all
  2012-04-11 12:12 ` Lars Magne Ingebrigtsen
@ 2012-04-11 17:55   ` Drew Adams
  2012-04-12  6:27     ` Chong Yidong
  2012-04-12 12:28     ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Drew Adams @ 2012-04-11 17:55 UTC (permalink / raw)
  To: 'Lars Magne Ingebrigtsen', 'Kazuo YAGI'; +Cc: 434

> Narrowing to the current function to search around in it
> (especially when refactoring) is something that I often do
> "manually", so having a handy keystroke for it would 
> be nice, I think.
> 
> `C-x n f', for instance, to toggle narrowing to the current function.
> 
> Opinions?

YAGNI.  `narrow-to-defun' is `C-x n d'.  We don't need a toggle for each
narrowing command.  And certainly not another key binding.

This is the kind of thing that any user can do, if desired.  There are lots of
commands that some users might want to bind.  It is trivial for a user to do so.
No need for Emacs to do this by default.  One opinion.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all
  2012-04-11 17:55   ` bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all Drew Adams
@ 2012-04-12  6:27     ` Chong Yidong
  2012-04-12 12:28     ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Chong Yidong @ 2012-04-12  6:27 UTC (permalink / raw)
  To: Drew Adams; +Cc: 434, 'Lars Magne Ingebrigtsen', 'Kazuo YAGI'

"Drew Adams" <drew.adams@oracle.com> writes:

>> Narrowing to the current function to search around in it (especially
>> when refactoring) is something that I often do "manually", so having
>> a handy keystroke for it would be nice, I think.
>> 
>> `C-x n f', for instance, to toggle narrowing to the current function.
>> 
>> Opinions?
>
> YAGNI.  `narrow-to-defun' is `C-x n d'.  We don't need a toggle for
> each narrowing command.  And certainly not another key binding.

Agreed.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all
  2012-04-11 17:55   ` bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all Drew Adams
  2012-04-12  6:27     ` Chong Yidong
@ 2012-04-12 12:28     ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-12 12:28 UTC (permalink / raw)
  To: Drew Adams; +Cc: 434, 'Kazuo YAGI'

"Drew Adams" <drew.adams@oracle.com> writes:

> YAGNI.  `narrow-to-defun' is `C-x n d'. 

I didn't know about that command, which should be sufficient.  I'm
closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-12 12:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-17  5:53 bug#434: Minor Enhancement: Toggle narrowing/widen a function region and all Kazuo YAGI
2012-04-11 12:12 ` Lars Magne Ingebrigtsen
2012-04-11 17:55   ` bug#434: Minor Enhancement: Toggle narrowing/widen a function regionand all Drew Adams
2012-04-12  6:27     ` Chong Yidong
2012-04-12 12:28     ` Lars Magne Ingebrigtsen

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).