From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: recentering for next-error Date: Thu, 21 Jun 2007 11:39:25 +0200 Message-ID: <87ejk5bq9e.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1182419052 2624 80.91.229.12 (21 Jun 2007 09:44:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Jun 2007 09:44:12 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 21 11:44:09 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I1JCz-0002C1-D1 for ged-emacs-devel@m.gmane.org; Thu, 21 Jun 2007 11:44:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I1JCy-0003ol-Ao for ged-emacs-devel@m.gmane.org; Thu, 21 Jun 2007 05:44:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I1JAM-0002ur-WA for emacs-devel@gnu.org; Thu, 21 Jun 2007 05:41:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I1JAL-0002uZ-NU for emacs-devel@gnu.org; Thu, 21 Jun 2007 05:41:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I1JAK-0002uI-UX for emacs-devel@gnu.org; Thu, 21 Jun 2007 05:41:25 -0400 Original-Received: from smtp-out2.libero.it ([212.52.84.42]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I1JAK-0002r1-2F for emacs-devel@gnu.org; Thu, 21 Jun 2007 05:41:24 -0400 Original-Received: from localhost (172.31.0.47) by smtp-out2.libero.it (7.3.120) id 4611FD980577A277 for emacs-devel@gnu.org; Thu, 21 Jun 2007 11:40:54 +0200 X-Scanned: with antispam and antivirus automated system at libero.it Original-Received: from smtp-out3.libero.it ([172.31.0.39]) by localhost (asav-out6.libero.it [192.168.32.34]) (amavisd-new, port 10024) with ESMTP id hDAwB59yU0Js for ; Thu, 21 Jun 2007 11:40:54 +0200 (CEST) Original-Received: from outrelay08.libero.it (192.168.32.103) by smtp-out3.libero.it (7.3.120) id 4611FDB6058AADE4 for emacs-devel@gnu.org; Thu, 21 Jun 2007 11:40:54 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AutRAIvkeUaXFSUJR2dsb2JhbACHI4dvAQE/ Original-Received: from ppp-9-37.21-151.libero.it (HELO ambire.localdomain) ([151.21.37.9]) by outrelay08.libero.it with ESMTP; 21 Jun 2007 11:39:39 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1I1J8W-0001QC-HD for emacs-devel@gnu.org; Thu, 21 Jun 2007 11:39:32 +0200 User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:73510 Archived-At: --=-=-= 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 ____________________________________ --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=.ttn.diff 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) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--