bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53764: 27.1; shouldn't ~/diary be in diary-mode?


From: Francesco Potortì
Subject: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Wed, 09 Feb 2022 19:21:03 +0100

Francesco Potortì <pot@gnu.org> writes:
>>>Do we have a convenience function that says whether we have a match in
>>>auto-mode-alist?  `set-auto-mode--apply-alist' seems to be the closest I
>>>can find, and...  it's not that close.  :-/  But I guess it could be
>>>refactored out of there.
>>
>> This one seems to do the job:
>> (add-to-list 'auto-mode-alist
>>           (cons diary-file 'diary-mode)
>>                 (lambda (a b) (equal (car a) (car b))))
>
>The user may have used a regexp like "diary$", "diary\\'", etc, so that
>doesn't work.

Sorry, I don't get it.  I am suggeting to add the name of the actual file (the 
one in diary-file) to the mode alist.  Looking for possible matches is a 
(small) optimisation. Why do we need a completely reliable matching code?

>>>We could move diary-file out of calendar.el and put it in...
>>>bindings.el or something, though?
>>
>> I would add it to the mode alist just after diary-file's defcustom
>
>As I said, that wouldn't help that much, because then you only get it
>added to auto-mode-alist after loading calendar.el (since there's where
>it's defined today).

In fact, both M-x diary and M-x appt-activate do load calendar, so it seems 
that any usage of diary, appointment or calendar functions would do the right 
thing, as long as the diary file is found after that.  Well, better than 
nothing, maybe.  In principle, after adding the hook, one could check whether 
any buffer is finding the diary file and change its mode...





reply via email to

[Prev in Thread] Current Thread [Next in Thread]