* buffer-name in find-file-hook
@ 2008-09-03 14:43 Joe Bloggs
2008-09-03 15:38 ` Joost Kremers
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Joe Bloggs @ 2008-09-03 14:43 UTC (permalink / raw)
To: help-gnu-emacs
Hi, I am writing a function to add to find-file-hook for hiding text regions saved in
a list. I need to know the buffer-name of the opened file, so that I can compare it
with the buffer names of the saved regions.
Here is the function:
;; hook for re-hiding regions when new file is opened
(defun hide-region-find-file-hook ()
(dolist (current hide-region-overlays)
(if (eq (buffer-name) (car current))
etc...
the problem is that the 'if' statement never evaluates to true.
I tried debugging in edebug, and both (buffer-name) and (car current)
evaluate to the same string, but for some reason the 'if' statement evaluates to 'nil'.
I have used the same construct in another function that is called from within the buffer,
and it works fine.
Can anyone help?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: buffer-name in find-file-hook
2008-09-03 14:43 buffer-name in find-file-hook Joe Bloggs
@ 2008-09-03 15:38 ` Joost Kremers
2008-09-03 15:44 ` Joe Bloggs
2008-09-03 17:57 ` Nikolaj Schumacher
[not found] ` <mailman.18339.1220464668.18990.help-gnu-emacs@gnu.org>
2 siblings, 1 reply; 6+ messages in thread
From: Joost Kremers @ 2008-09-03 15:38 UTC (permalink / raw)
To: help-gnu-emacs
Joe Bloggs wrote:
> (if (eq (buffer-name) (car current))
>
> the problem is that the 'if' statement never evaluates to true.
> I tried debugging in edebug, and both (buffer-name) and (car current)
> evaluate to the same string, but for some reason the 'if' statement evaluates to 'nil'.
check out the section on equality predicates in the elisp manual:
(info "(elisp) Equality Predicates")
--
Joost Kremers joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: buffer-name in find-file-hook
2008-09-03 14:43 buffer-name in find-file-hook Joe Bloggs
2008-09-03 15:38 ` Joost Kremers
@ 2008-09-03 17:57 ` Nikolaj Schumacher
[not found] ` <mailman.18339.1220464668.18990.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 6+ messages in thread
From: Nikolaj Schumacher @ 2008-09-03 17:57 UTC (permalink / raw)
To: Joe Bloggs; +Cc: help-gnu-emacs
Joe Bloggs <who@cares.invalid> wrote:
> Hi, I am writing a function to add to find-file-hook for hiding text
> regions saved in a list. I need to know the buffer-name of the opened
> file, so that I can compare it with the buffer names of the saved
> regions.
Why are you using the buffer name? Wouldn't it be better to use
something more unique, i.e. the file name?
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.18339.1220464668.18990.help-gnu-emacs@gnu.org>]
* Re: buffer-name in find-file-hook
[not found] ` <mailman.18339.1220464668.18990.help-gnu-emacs@gnu.org>
@ 2008-09-12 22:21 ` Joe Bloggs
2008-09-14 21:10 ` Nikolaj Schumacher
0 siblings, 1 reply; 6+ messages in thread
From: Joe Bloggs @ 2008-09-12 22:21 UTC (permalink / raw)
To: help-gnu-emacs
Nikolaj Schumacher <me@nschum.de> writes:
> Joe Bloggs <who@cares.invalid> wrote:
>
>> Hi, I am writing a function to add to find-file-hook for hiding text
>> regions saved in a list. I need to know the buffer-name of the opened
>> file, so that I can compare it with the buffer names of the saved
>> regions.
>
> Why are you using the buffer name? Wouldn't it be better to use
> something more unique, i.e. the file name?
>
>
> regards,
> Nikolaj Schumacher
I figured that I may want to move the file, but still keep the hidden regions.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: buffer-name in find-file-hook
2008-09-12 22:21 ` Joe Bloggs
@ 2008-09-14 21:10 ` Nikolaj Schumacher
0 siblings, 0 replies; 6+ messages in thread
From: Nikolaj Schumacher @ 2008-09-14 21:10 UTC (permalink / raw)
To: Joe Bloggs; +Cc: help-gnu-emacs
Joe Bloggs <who@cares.invalid> wrote:
> Nikolaj Schumacher <me@nschum.de> writes:
>
>> Joe Bloggs <who@cares.invalid> wrote:
>>
>>> Hi, I am writing a function to add to find-file-hook for hiding text
>>> regions saved in a list. I need to know the buffer-name of the opened
>>> file, so that I can compare it with the buffer names of the saved
>>> regions.
>>
>> Why are you using the buffer name? Wouldn't it be better to use
>> something more unique, i.e. the file name?
>>
>>
>> regards,
>> Nikolaj Schumacher
>
> I figured that I may want to move the file, but still keep the hidden
> regions.
Unfortunately files of the same name (say "README") will then also share
the same hidden regions. On the other hand, buffers can be renamed or
"uniquified" and lose settings.
Maybe you could generate a hash to catch renamed files.
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-14 21:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-03 14:43 buffer-name in find-file-hook Joe Bloggs
2008-09-03 15:38 ` Joost Kremers
2008-09-03 15:44 ` Joe Bloggs
2008-09-03 17:57 ` Nikolaj Schumacher
[not found] ` <mailman.18339.1220464668.18990.help-gnu-emacs@gnu.org>
2008-09-12 22:21 ` Joe Bloggs
2008-09-14 21:10 ` Nikolaj Schumacher
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).