unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* recentering for next-error
@ 2007-06-21  9:39 Thien-Thi Nguyen
  2007-06-21  9:50 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thien-Thi Nguyen @ 2007-06-21  9:39 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 962 bytes --]

sometimes i grep "lambda", and would like to see the hits `next-error'
displays such that the hit is near the top of the window w/ the body (of
the lambda) following.  the attached diff adds this recentering capability,
and additionally makes it easier to tweak.

here are two equivalent customizations to demonstrate the change:

 cur: (add-hook 'next-error-hook (lambda () (recenter 2)) t)
 new: (setq next-error-recenter 2)

to change recentering behavior, the current method requires replacing the
anonymous function in `next-error-hook' with another one.  the new method
is less cumbersome.  on the downside, expanding `next-error' "API" can be
considered unnecessary feature creep.

here is a changelog entry:

	* simple.el (next-error-recenter): New defcustom.
	(next-error, next-error-internal): Recenter if specified,
	immediately prior to running `next-error-hook'.

below is the diff.  what do people think?

thi

____________________________________

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: .ttn.diff --]
[-- Type: text/x-diff, Size: 1582 bytes --]

Index: simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.861
diff -c -r1.861 simple.el
*** simple.el	20 May 2007 03:12:20 -0000	1.861
--- simple.el	21 Jun 2007 09:15:00 -0000
***************
*** 156,161 ****
--- 156,169 ----
    :group 'next-error
    :version "22.1")
  
+ (defcustom next-error-recenter nil
+   "*Display the line in the visited source file recentered to this number.
+ If nil, don't do any recentering."
+   :type '(choice (number :tag "Argument for `recenter'")
+                  (const :tag "No recentering" nil))
+   :group 'next-error
+   :version "23.1")
+ 
  (defcustom next-error-hook nil
    "*List of hook functions run by `next-error' after visiting source file."
    :type 'hook
***************
*** 305,310 ****
--- 313,320 ----
      ;; we know here that next-error-function is a valid symbol we can funcall
      (with-current-buffer next-error-last-buffer
        (funcall next-error-function (prefix-numeric-value arg) reset)
+       (when next-error-recenter
+         (recenter next-error-recenter))
        (run-hooks 'next-error-hook))))
  
  (defun next-error-internal ()
***************
*** 313,318 ****
--- 323,330 ----
    ;; we know here that next-error-function is a valid symbol we can funcall
    (with-current-buffer next-error-last-buffer
      (funcall next-error-function 0 nil)
+     (when next-error-recenter
+       (recenter next-error-recenter))
      (run-hooks 'next-error-hook)))
  
  (defalias 'goto-next-locus 'next-error)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

end of thread, other threads:[~2007-06-22 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21  9:39 recentering for next-error Thien-Thi Nguyen
2007-06-21  9:50 ` Andreas Schwab
2007-06-22  1:51 ` Richard Stallman
2007-06-22 19:32 ` Juri Linkov
2007-06-22 22:11   ` Thien-Thi Nguyen
2007-06-22 22:22     ` Juri Linkov

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