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

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

bug#434: Minor Enhancement: Toggle narrowing/widen a function region and


From: Kazuo YAGI
Subject: bug#434: Minor Enhancement: Toggle narrowing/widen a function region and all
Date: Tue, 17 Jun 2008 14:53:18 +0900
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

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








reply via email to

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