[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Evaluation of hooks
From: |
Tom Breton |
Subject: |
Re: Evaluation of hooks |
Date: |
24 Dec 2005 21:36:32 -0500 |
User-agent: |
Gnus/5.0802 (Gnus v5.8.2) Emacs/20.4 |
Sebastian Tennant <sebyte@smolny.plus.com> writes:
> Hi all,
>
> I would like to add a function to my emacs-lisp-mode-hook so that whenever I
> visit emacs source files, view-mode minor mode is enabled.
>
> (add-hook 'emacs-lisp-mode-hook
> (lambda ()
> (when (>= (compare-strings
> (buffer-file-name) 1 nil "/usr/share/emacs/" 1 nil) 17)
> (view-mode-enable))))
>
> With the above code in my ~/.emacs, I get the following message at startup:
>
> >: Wrong type argument: stringp, nil
I doubt that has anything to do with hooks.
> but apart from this the startup process is unaffected, and the function is
> successfully added to my emacs-lisp-mode-hook, as you can see:
>
> ((lambda nil
> (when
> (>
> (compare-strings
> (buffer-file-name)
> 0 nil "/usr/share/emacs/" 0 nil)
> 18)
> (view-mode-enable))))
Nope, that doesn't work either ... sometimes.
Try it in a few different buffers - especially those like *Article*
that aren't visiting a file. The result is different depending on
what buffer you try it in.
The bug seems to be that when `buffer-file-name' does not return a
string, `compare-strings' justifiably barfs.
--
Tom Breton, the calm-eyed visionary
Ho ho ho, Merry Whatever!