From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: emacs-devel@gnu.org
Subject: recentering for next-error
Date: Thu, 21 Jun 2007 11:39:25 +0200 [thread overview]
Message-ID: <87ejk5bq9e.fsf@ambire.localdomain> (raw)
[-- 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
next reply other threads:[~2007-06-21 9:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-21 9:39 Thien-Thi Nguyen [this message]
2007-06-21 9:50 ` recentering for next-error 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ejk5bq9e.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).