[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: another simple question about hooks
From: |
David Z Maze |
Subject: |
Re: another simple question about hooks |
Date: |
Mon, 12 Nov 2007 13:14:57 -0500 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/21.4 (usg-unix-v) |
David Rod <angel_ov_north@tiscali.co.uk> writes:
> (defun david-r-turn-on-text-stuff ()
> (flyspell-mode 1)
> (abbrev-mode 1)
> )
>
> (add-hook 'text-mode-hook 'david-r-turn-on-text-stuff)
>
> this works fine. I want to add a (mark-whole-buffer)
> (canonically-space-region)
> Whenever I try this, this renders new messages and follow-ups
> by gnus inoperable
You probably got a better response on how to call
canonically-space-region with point-min and point-max, but it's good
style to call elisp code that indirectly manipulates the point or mark
inside a save-excursion block as well. (text-mode-hook might get called
in a context where the point is assumed to be somewhere else, like the
start of the message body.) The help I have for `C-h f
mark-whole-buffer' states that "it is usually a mistake for a Lisp
function to use any subrouten that uses or sets the mark".
> Also another question. is there a hook by killing a buffer which
> contains a file with the extension as .txt ?
Not a Gnus question per se, but kill-buffer-hook gets called with the
buffer being killed as the current buffer, so you can look at
buffer-local variables like major-mode to see.
--dzm