From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Newsgroups: gmane.emacs.help Subject: Re: Mode for files visited by GUD Date: Fri, 18 Jul 2008 03:08:34 +0200 Message-ID: <200807180308.34236.juanma_bellon@yahoo.es> References: <200807170135.53892.juanma_bellon@yahoo.es> <200807180154.59785.juanma_bellon@yahoo.es> <18559.58408.326814.857256@kahikatea.snap.net.nz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216343360 347 80.91.229.12 (18 Jul 2008 01:09:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jul 2008 01:09:20 +0000 (UTC) To: help-gnu-emacs@gnu.org, Nick Roberts Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 18 03:10:07 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KJeU2-0006q4-Td for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Jul 2008 03:10:07 +0200 Original-Received: from localhost ([127.0.0.1]:45287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJeT9-0007a3-Bn for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Jul 2008 21:09:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJeSh-0007TV-TE for help-gnu-emacs@gnu.org; Thu, 17 Jul 2008 21:08:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJeSc-0007Q9-Hl for help-gnu-emacs@gnu.org; Thu, 17 Jul 2008 21:08:43 -0400 Original-Received: from [199.232.76.173] (port=51578 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJeSc-0007Q3-DU for help-gnu-emacs@gnu.org; Thu, 17 Jul 2008 21:08:38 -0400 Original-Received: from n3.bullet.mail.re3.yahoo.com ([68.142.237.110]:27485) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KJeSb-0008MU-Fe for help-gnu-emacs@gnu.org; Thu, 17 Jul 2008 21:08:38 -0400 Original-Received: from [68.142.237.87] by n3.bullet.mail.re3.yahoo.com with NNFMP; 18 Jul 2008 01:08:35 -0000 Original-Received: from [216.252.111.169] by t3.bullet.re3.yahoo.com with NNFMP; 18 Jul 2008 01:08:34 -0000 Original-Received: from [127.0.0.1] by omp104.mail.re3.yahoo.com with NNFMP; 18 Jul 2008 01:08:34 -0000 X-Yahoo-Newman-Id: 963215.9160.bm@omp104.mail.re3.yahoo.com Original-Received: (qmail 66300 invoked from network); 18 Jul 2008 01:08:34 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.es; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id; b=S6DApZEPvju3+PDNq8QXX42PYQa2Ir12ZszDpJCpOCUG2FmjbyeAUo+T0nyR4f4jMlq47bIOxLml7SQuKhI8iR7vJOE8JmZW5YKoNNA7GVkjPm06gjBgpEGpTSXLmxRKLG8+UbSxFxzZ02KqMpu5mKIozQmduxPCVcmUJUWIRYI= ; Original-Received: from unknown (HELO 212251168194.customer.cdi.no) (juanma_bellon@212.251.168.194 with plain) by smtp112.plus.mail.re1.yahoo.com with SMTP; 18 Jul 2008 01:08:34 -0000 X-YMail-OSG: Ov_DpckVM1le5W0Fx_1c30mPeQ1rWARcQp3ua0ujRRGgMPVqwGWgFmb94G9L1PXt0CvXUtIZRO8yGbmmuc7oTNTC0cHPy0w5UcgjgUsZUjh88KJv1td4em5mE0z9MIaKiy8- X-Yahoo-Newman-Property: ymail-3 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) In-Reply-To: <18559.58408.326814.857256@kahikatea.snap.net.nz> Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:55688 Archived-At: > > documented on a user level, while the variable was not. Maybe the variable > > was created by my mistake only, as I hooked my function on it? > > What variable? There is no variable gdb-find-file-hook and the variable > find-file-hook is documented in the Elisp manual. What I thought: there *was* no such variable, until I did (add-hook 'gdb-find-file-hook 'my-stuff) Of course, it didn't help with anything :-) The thing is, I did it before realizing that it wasn't a hook variable, but a function. I had overlooked that you said "You could advise that function". > > So, yes, I can advice that function, but, anything against using a hook > > variable instead? > > I'm not sure what you mean. Oh, never mind. I was curious as to why making 'gdb-find-file-hook' a function instead of a hook variable, but you already explained that it was a design decision. > gdb-find-file-hook is added to find-file-hook which _is_ a hook variable Yes, I noticed it. And I don't understand the whole procedure. With this mechanism, is there any difference between advising 'gdb-find-file-hook', and directly hooking my functions in 'find-file-hook'? The result seems to be the same in the end, and it's not what I wanted. I did not want my functions to be run for every file loaded into Emacs (at least, loaded in any way that would cause the execution of 'find-file-hook'). > Advising functions has it's own problems as described in the Elisp manual. > > What is it you are trying to do? If your changes are of general interest, > maybe we could include them in Emacs. I want to turn on a minor mode for source code files visited during debugging. I want to make them read-only and have many commands bound to single keys (I use View mode in addition to my minor mode). The minor mode is this: ---------------------------------------- (define-minor-mode source-guding-mode "Toggle source-GUDing minor mode. With prefix ARG, turn source-GUDing mode on if ARG is positive, off otherwise. When source-GUDing mode is on for a buffer, View mode is activated (so the buffer is turned read-only) and GUD commands are assigned to very simple keystrokes (typically one key). Here is the list of those: \\{source-guding-mode-map}" ;; Initial value for the minor mode variable (off) nil ;; Indicator for the mode line " *GUDing*" ;; We can provide a keymap for the minor mode or we can better to ;; provide the key bindings in a list (better in this case) '(([return] . gud-go) ; start or continue execution ("b" . gud-break) ; set a breakpoint ("D" . gud-remove) ; delete breakpoint in current line, if any ("n" . gud-next) ; execute next expression, but don't enter any functions ("s" . gud-step) ; execute next expression, stepping into functions ("c" . gud-cont) ; continue execution ("u" . gud-until) ; run until cursor ("J" . gud-jump) ; move execution point to current line (">" . gud-down) ; go down N stack frames (needs num. arg.) ("<" . gud-up) ; go up N stack frames (needs num. arg.) ("t" . gud-tbreak) ; set temporary breakpoint ("p" . gud-print) ; print expression at point ("d" . gud-pstar) ; print C-dereferenced expression at point ([f5] . gud-refresh) ; show current execution point (and re-draw screen) ("q" . source-guding-mode)) ; quit this mode (also toggle View mode) ;; Customization group :group gud ;; Body of the mode (view-mode source-guding-mode)) ; the value of the minor mode var. will ; determine whether to turn on or off the ; associated View mode ---------------------------------------- Then I have this in my .emacs: (autoload 'source-guding-mode "source-guding.el") (defadvice gdb-find-file-hook (after activate-guding activate) (source-guding-mode 1)) -- Juanma "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr