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

Previous Next

Package: emacs;

Reported by: Francesco Potortì <pot <at> gnu.org>

Date: Thu, 3 Feb 2022 22:13:01 UTC

Severity: wishlist

Found in version 27.1

To reply to this bug, email your comments to 53764 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Thu, 03 Feb 2022 22:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Francesco Potortì <pot <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 03 Feb 2022 22:13:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; shouldn't ~/diary be in diary-mode?
Date: Thu, 03 Feb 2022 23:12:19 +0100
Is there any reason why the ~/diary file is not read in diary-mode?

Shouldn't it be in the auto-mode-alist?

Maybe the reason is that the name of the diary is contained in the diay-file variable and can thus be changed?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Sat, 05 Feb 2022 06:55:02 GMT) Full text and rfc822 format available.

Message #8 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Francesco Potortì <pot <at> gnu.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Sat, 05 Feb 2022 07:54:39 +0100
Francesco Potortì <pot <at> gnu.org> writes:

> Is there any reason why the ~/diary file is not read in diary-mode?
>
> Shouldn't it be in the auto-mode-alist?
>
> Maybe the reason is that the name of the diary is contained in the
> diay-file variable and can thus be changed?

I think putting any file that's called "diary" in diary-mode would
probably lead to too many false positives?  "~/.emacs.d/diary" (which is
the default on many platforms) could safely be put in diary mode,
though, but I'm not sure that would be all that helpful in practice...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 05 Feb 2022 06:55:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Sat, 05 Feb 2022 15:03:01 GMT) Full text and rfc822 format available.

Message #13 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Sat, 05 Feb 2022 16:02:30 +0100
>Francesco Potortì <pot <at> gnu.org> writes:
>> Is there any reason why the ~/diary file is not read in diary-mode?
>>
>> Shouldn't it be in the auto-mode-alist?
>>
>> Maybe the reason is that the name of the diary is contained in the
>> diay-file variable and can thus be changed?

Lars:
>I think putting any file that's called "diary" in diary-mode would
>probably lead to too many false positives?  "~/.emacs.d/diary" (which is
>the default on many platforms) could safely be put in diary mode,
>though, but I'm not sure that would be all that helpful in practice...

When calendar is loaded, diary-file is initialised.  After that, it could be added to the auto-mode-alist.

The reason I am asking is that I have used the diary for years, and only recently, by looking at the source code for other reasons, did I discover that a diary-mode exists.

Now I have added -*-diary-*- line to my diary file, but in fact that should be automatic, I think.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Sat, 05 Feb 2022 21:55:02 GMT) Full text and rfc822 format available.

Message #16 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Francesco Potortì <pot <at> gnu.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Sat, 05 Feb 2022 22:54:07 +0100
Francesco Potortì <pot <at> gnu.org> writes:

> When calendar is loaded, diary-file is initialised.  After that, it
> could be added to the auto-mode-alist.

That's true.  Grepping around, it looks like we have a number of other
packages that also add to `auto-mode-alist', so there's some precedence
for doing this, but I'm a bit unsure in this case.  That is, the user
may have added something to auto-mode-alist themselves, and we don't
want to override that.

But I guess it's pretty unlikely.  Does anybody have an opinion?

> The reason I am asking is that I have used the diary for years, and
> only recently, by looking at the source code for other reasons, did I
> discover that a diary-mode exists.
>
> Now I have added -*-diary-*- line to my diary file, but in fact that
> should be automatic, I think.

I think the idea is that you view the diary via the `d' command in
Calendar, and that puts the file in diary mode, I think?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Sat, 05 Feb 2022 23:12:02 GMT) Full text and rfc822 format available.

Message #19 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Sun, 06 Feb 2022 00:11:08 +0100
>Francesco Potortì <pot <at> gnu.org> writes:
>> When calendar is loaded, diary-file is initialised.  After that, it
>> could be added to the auto-mode-alist.

Lars:
>That's true.  Grepping around, it looks like we have a number of other
>packages that also add to `auto-mode-alist', so there's some precedence
>for doing this, but I'm a bit unsure in this case.  That is, the user
>may have added something to auto-mode-alist themselves, and we don't
>want to override that.
>
>But I guess it's pretty unlikely.  Does anybody have an opinion?

If diary-file is already in the auto-mode-alist, we do nothing.  No override.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Sun, 06 Feb 2022 03:56:01 GMT) Full text and rfc822 format available.

Message #22 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Francesco Potortì <pot <at> gnu.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Sun, 06 Feb 2022 04:54:54 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> But I guess it's pretty unlikely.  Does anybody have an opinion?

I vote "do it".  People will rather change `diary-mode' than writing
something own from scratch.  The - not unuseful - mode is too hard to
discover currently.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Sun, 06 Feb 2022 23:08:01 GMT) Full text and rfc822 format available.

Message #25 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Francesco Potortì <pot <at> gnu.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 00:07:42 +0100
Francesco Potortì <pot <at> gnu.org> writes:

> If diary-file is already in the auto-mode-alist, we do nothing.  No override.

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.

Michael Heerdegen <michael_heerdegen <at> web.de> writes:

>> But I guess it's pretty unlikely.  Does anybody have an opinion?
>
> I vote "do it".  People will rather change `diary-mode' than writing
> something own from scratch.  The - not unuseful - mode is too hard to
> discover currently.

We have a chicken/egg problem, though.  Adding `diary-file' to
`auto-mode-alist' would be fine, but we calculate that in calendar.el,
so people not using the calendar won't get the mode.

We could move diary-file out of calendar.el and put it in...
bindings.el or something, though?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 00:40:01 GMT) Full text and rfc822 format available.

Message #28 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Francesco Potortì <pot <at> gnu.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 01:39:37 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> We have a chicken/egg problem, though.  Adding `diary-file' to
> `auto-mode-alist' would be fine, but we calculate that in calendar.el,
> so people not using the calendar won't get the mode.
>
> We could move diary-file out of calendar.el and put it in...
> bindings.el or something, though?

I'm not sure anymore if this is a good idea anyway, because (doc of
`diary-file'): "Diary files can contain directives to include the
contents of other files; for details, see the documentation for the
variable `diary-list-entries-hook'".

No magic is able to ensure that all of these files are always opened
with the right mode.

Dunno.  When the diary-file is opened with `diary-show-all-entries', the
mode is already changed to diary-mode.  We could automatically add a
file local variable when Emacs creates the (main) diary file for the
user.

An alternative approach: we change the name of the diary-file to .diary
and associate the suffix ".diary" with diary-mode.  When the user then
names his/her included diary files like "holidays.diary" and
"work.diary", the mode would be enabled for these files, too.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 03:46:01 GMT) Full text and rfc822 format available.

Message #31 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Francesco Potortì <pot <at> gnu.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 04:45:41 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> I'm not sure anymore if this is a good idea anyway, because (doc of
> `diary-file'): "Diary files can contain directives to include the
> contents of other files; for details, see the documentation for the
> variable `diary-list-entries-hook'".
>
> No magic is able to ensure that all of these files are always opened
> with the right mode.

Hm, right.

> Dunno.  When the diary-file is opened with `diary-show-all-entries', the
> mode is already changed to diary-mode.  We could automatically add a
> file local variable when Emacs creates the (main) diary file for the
> user.
>
> An alternative approach: we change the name of the diary-file to .diary
> and associate the suffix ".diary" with diary-mode.  When the user then
> names his/her included diary files like "holidays.diary" and
> "work.diary", the mode would be enabled for these files, too.

Hm...  is that worth it?  People are bound to end up with both a
~/.emacs.d/diary and ~/.emacs.d/diary.diary file when they switch
between newer and older Emacs versions.  Renaming files like this is
always painful.

Perhaps we should just do nothing -- people normally access the diary
file via Calendar, which does everything it's supposed to.  Loading the
diary file with `C-x C-f' is probably something most people don't do.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 04:18:02 GMT) Full text and rfc822 format available.

Message #34 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Francesco Potortì <pot <at> gnu.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 05:17:21 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Perhaps we should just do nothing

Yes, perhaps.

> -- people normally access the diary file via Calendar, which does
> everything it's supposed to.  Loading the diary file with `C-x C-f' is
> probably something most people don't do.

But I would not assume that.  People living "everything is a file" do
it.  I didn't know about the mode until I participated in this
discussion, I thought the highlighting would be some magic the diary
does when diary entries are displayed from the calendar, I didn't know
it's just a simple major mode.

And it's not necessary to use the calendar key interface to use the
diary, e.g. for calendar highlighting stuff or annotations.  It isn't
convenient to add complicated diary expressions or #includes to the
diary file from the calendar.  It's legitimate to edit the file the
normal way.

Maybe we can leave a short remark about the existence of the mode in the
manual?

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 05:09:01 GMT) Full text and rfc822 format available.

Message #37 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: larsi <at> gnus.org, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 00:08:00 -0500
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I think this change is a good one -- it is natural for Diary
mode to be selected by default.

But there is one thing I ask people to make sure of.

I edit my diary file in Fundamental mode.  I don't keep
it in the precise format Diary mode requires.

So please make sure that -*-fundamental-*- in the first line
overrides the new default.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 08:27:02 GMT) Full text and rfc822 format available.

Message #40 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Francesco Potortì <pot <at> gnu.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 09:25:57 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Maybe we can leave a short remark about the existence of the mode in the
> manual?

We could also have `diary-make-entry' put a diary mode cookie into the
diary file (if the file doesn't exist already).

That'd make the buffer a big uglier when editing it from Calendar (with
`i d' etc), though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 09:11:02 GMT) Full text and rfc822 format available.

Message #43 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 10:10:04 +0100
>Francesco Potortì <pot <at> gnu.org> writes:
>> If diary-file is already in the auto-mode-alist, we do nothing.  No override.
>
>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))))

>Michael Heerdegen <michael_heerdegen <at> web.de> writes:
>> I vote "do it".  People will rather change `diary-mode' than writing
>> something own from scratch.  The - not unuseful - mode is too hard to
>> discover currently.

That was my point, in fact.

>We have a chicken/egg problem, though.  Adding `diary-file' to
>`auto-mode-alist' would be fine, but we calculate that in calendar.el,
>so people not using the calendar won't get the mode.

That would not do a complete job.  I have used M-x diary for years before ever trying M-x calendar.  Occasionally I suse calendar today, but mst of the time I add entries to diary by hand.  I have (appt-activate t) in my .emacs.

>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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 09:29:01 GMT) Full text and rfc822 format available.

Message #46 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Francesco Potortì <pot <at> gnu.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 10:28:07 +0100
Francesco Potortì <pot <at> 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.

>>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).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 19:51:02 GMT) Full text and rfc822 format available.

Message #49 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Mon, 07 Feb 2022 21:39:00 +0200
> Perhaps we should just do nothing -- people normally access the diary
> file via Calendar, which does everything it's supposed to.  Loading the
> diary file with `C-x C-f' is probably something most people don't do.

The only case when I see the diary file is when quitting Calendar
leaves the diary buffer floating in the buffer list, so every time after
using Calendar have to visit the diary buffer and manually kill it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Mon, 07 Feb 2022 23:51:01 GMT) Full text and rfc822 format available.

Message #52 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Tue, 08 Feb 2022 00:50:51 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> We could also have `diary-make-entry' put a diary mode cookie into the
> diary file (if the file doesn't exist already).
>
> That'd make the buffer a big uglier when editing it from Calendar (with
> `i d' etc), though.

For me, by far no reason not to do that.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Tue, 08 Feb 2022 01:17:02 GMT) Full text and rfc822 format available.

Message #55 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Tue, 08 Feb 2022 14:16:50 +1300
On 2022-02-07 13:39, Michael Heerdegen wrote:
> We could automatically add a file local variable when Emacs
> creates the (main) diary file for the user.

To me this seems *much* better than the "do nothing" option.

People who don't want it can just delete the file-local var,
or change it to specify a different mode.

It won't directly help people with pre-existing diary files,
but if the change is called out in NEWS then those users can
be alerted to the fact that they might want to make that
change manually.


-Phil





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Tue, 08 Feb 2022 06:12:02 GMT) Full text and rfc822 format available.

Message #58 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Tue, 08 Feb 2022 07:11:00 +0100
Juri Linkov <juri <at> linkov.net> writes:

> The only case when I see the diary file is when quitting Calendar
> leaves the diary buffer floating in the buffer list, so every time after
> using Calendar have to visit the diary buffer and manually kill it.

That buffer is included in `calendar-buffer-list', so `calendar-exit'
calls `quit-window' on that buffer.  So you could have
`quit-window-hook' kill the buffer, I guess?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Wed, 09 Feb 2022 18:04:01 GMT) Full text and rfc822 format available.

Message #61 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Wed, 09 Feb 2022 19:03:32 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
>> Maybe we can leave a short remark about the existence of the mode in the
>> manual?

I'd say definitely yes.

>We could also have `diary-make-entry' put a diary mode cookie into the
>diary file (if the file doesn't exist already).
>
>That'd make the buffer a big uglier when editing it from Calendar (with
>`i d' etc), though.

Only if the mode is set at the end of file, I think that putting the
-*- diary -*- string at the beginning would not make it bad.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Wed, 09 Feb 2022 18:22:02 GMT) Full text and rfc822 format available.

Message #64 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Wed, 09 Feb 2022 19:21:03 +0100
Francesco Potortì <pot <at> 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...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Wed, 09 Feb 2022 21:27:01 GMT) Full text and rfc822 format available.

Message #67 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Francesco Potortì <pot <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Wed, 09 Feb 2022 22:26:37 +0100
On Feb 09 2022, Francesco Potortì wrote:

> Francesco Potortì <pot <at> 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?

If you put it at the end, it won't hide any preexisting match.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53764; Package emacs. (Wed, 09 Feb 2022 21:53:02 GMT) Full text and rfc822 format available.

Message #70 received at 53764 <at> debbugs.gnu.org (full text, mbox):

From: Francesco Potortì <pot <at> gnu.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53764 <at> debbugs.gnu.org
Subject: Re: bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
Date: Wed, 09 Feb 2022 22:52:48 +0100
>>>>>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?
>
>If you put it at the end, it won't hide any preexisting match.

Little matter, in my opinion.  If the user haa set up anything, that will match.  It's okay.  We don't want to hide anything.  We just want to improve user experience in the common case when the user has not read the source code and does not know about diary-mode.




Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 14 Mar 2022 10:35:03 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 94 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.