unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
@ 2022-02-03 22:12 Francesco Potortì
  2022-02-05  6:54 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 24+ messages in thread
From: Francesco Potortì @ 2022-02-03 22:12 UTC (permalink / raw)
  To: 53764

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?





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-03 22:12 bug#53764: 27.1; shouldn't ~/diary be in diary-mode? Francesco Potortì
@ 2022-02-05  6:54 ` Lars Ingebrigtsen
  2022-02-05 15:02   ` Francesco Potortì
  0 siblings, 1 reply; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-05  6:54 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-05  6:54 ` Lars Ingebrigtsen
@ 2022-02-05 15:02   ` Francesco Potortì
  2022-02-05 21:54     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 24+ messages in thread
From: Francesco Potortì @ 2022-02-05 15:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

>Francesco Potortì <pot@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-05 15:02   ` Francesco Potortì
@ 2022-02-05 21:54     ` Lars Ingebrigtsen
  2022-02-05 23:11       ` Francesco Potortì
  2022-02-06  3:54       ` Michael Heerdegen
  0 siblings, 2 replies; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-05 21:54 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-05 21:54     ` Lars Ingebrigtsen
@ 2022-02-05 23:11       ` Francesco Potortì
  2022-02-06 23:07         ` Lars Ingebrigtsen
  2022-02-06  3:54       ` Michael Heerdegen
  1 sibling, 1 reply; 24+ messages in thread
From: Francesco Potortì @ 2022-02-05 23:11 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

>Francesco Potortì <pot@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-05 21:54     ` Lars Ingebrigtsen
  2022-02-05 23:11       ` Francesco Potortì
@ 2022-02-06  3:54       ` Michael Heerdegen
  2022-02-07  5:08         ` Richard Stallman
  1 sibling, 1 reply; 24+ messages in thread
From: Michael Heerdegen @ 2022-02-06  3:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-05 23:11       ` Francesco Potortì
@ 2022-02-06 23:07         ` Lars Ingebrigtsen
  2022-02-07  0:39           ` Michael Heerdegen
  2022-02-07  9:10           ` Francesco Potortì
  0 siblings, 2 replies; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-06 23:07 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-06 23:07         ` Lars Ingebrigtsen
@ 2022-02-07  0:39           ` Michael Heerdegen
  2022-02-07  3:45             ` Lars Ingebrigtsen
  2022-02-08  1:16             ` bug#53764: 27.1; shouldn't ~/diary be in diary-mode? Phil Sainty
  2022-02-07  9:10           ` Francesco Potortì
  1 sibling, 2 replies; 24+ messages in thread
From: Michael Heerdegen @ 2022-02-07  0:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  0:39           ` Michael Heerdegen
@ 2022-02-07  3:45             ` Lars Ingebrigtsen
  2022-02-07  4:17               ` Michael Heerdegen
  2022-02-07 19:39               ` Juri Linkov
  2022-02-08  1:16             ` bug#53764: 27.1; shouldn't ~/diary be in diary-mode? Phil Sainty
  1 sibling, 2 replies; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-07  3:45 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 53764

Michael Heerdegen <michael_heerdegen@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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  3:45             ` Lars Ingebrigtsen
@ 2022-02-07  4:17               ` Michael Heerdegen
  2022-02-07  8:25                 ` Lars Ingebrigtsen
  2022-02-07 19:39               ` Juri Linkov
  1 sibling, 1 reply; 24+ messages in thread
From: Michael Heerdegen @ 2022-02-07  4:17 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-06  3:54       ` Michael Heerdegen
@ 2022-02-07  5:08         ` Richard Stallman
  0 siblings, 0 replies; 24+ messages in thread
From: Richard Stallman @ 2022-02-07  5:08 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: larsi, 53764

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







^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  4:17               ` Michael Heerdegen
@ 2022-02-07  8:25                 ` Lars Ingebrigtsen
  2022-02-07 23:50                   ` Michael Heerdegen
  2022-02-09 18:03                   ` Francesco Potortì
  0 siblings, 2 replies; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-07  8:25 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 53764

Michael Heerdegen <michael_heerdegen@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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-06 23:07         ` Lars Ingebrigtsen
  2022-02-07  0:39           ` Michael Heerdegen
@ 2022-02-07  9:10           ` Francesco Potortì
  2022-02-07  9:28             ` Lars Ingebrigtsen
  1 sibling, 1 reply; 24+ messages in thread
From: Francesco Potortì @ 2022-02-07  9:10 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  9:10           ` Francesco Potortì
@ 2022-02-07  9:28             ` Lars Ingebrigtsen
  2022-02-09 18:21               ` Francesco Potortì
  0 siblings, 1 reply; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-07  9:28 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 53764

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.

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  3:45             ` Lars Ingebrigtsen
  2022-02-07  4:17               ` Michael Heerdegen
@ 2022-02-07 19:39               ` Juri Linkov
  2022-02-08  6:11                 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 24+ messages in thread
From: Juri Linkov @ 2022-02-07 19:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Michael Heerdegen, 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  8:25                 ` Lars Ingebrigtsen
@ 2022-02-07 23:50                   ` Michael Heerdegen
  2022-02-09 18:03                   ` Francesco Potortì
  1 sibling, 0 replies; 24+ messages in thread
From: Michael Heerdegen @ 2022-02-07 23:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  0:39           ` Michael Heerdegen
  2022-02-07  3:45             ` Lars Ingebrigtsen
@ 2022-02-08  1:16             ` Phil Sainty
  1 sibling, 0 replies; 24+ messages in thread
From: Phil Sainty @ 2022-02-08  1:16 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Lars Ingebrigtsen, 53764

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






^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07 19:39               ` Juri Linkov
@ 2022-02-08  6:11                 ` Lars Ingebrigtsen
  2022-02-08  7:39                   ` bug#53870: calendar-exit doesn't kill calendar buffers Juri Linkov
  0 siblings, 1 reply; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-08  6:11 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Michael Heerdegen, 53764

Juri Linkov <juri@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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53870: calendar-exit doesn't kill calendar buffers
  2022-02-08  6:11                 ` Lars Ingebrigtsen
@ 2022-02-08  7:39                   ` Juri Linkov
  2022-02-09  8:32                     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 24+ messages in thread
From: Juri Linkov @ 2022-02-08  7:39 UTC (permalink / raw)
  To: 53870

[This is a separate bug report from bug#53764.]

>> 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?

The problem is that when the KILL arg of calendar-exit is non-nil,
it still doesn't kill calendar buffers.

When calendar-setup is non-nil, it doesn't kill all calendar buffers
because ‘(quit-window kill w)’ is called only on windows, but not on
non-displayed buffers.

When calendar-setup is nil, it doesn't kill all calendar buffers
because ‘(quit-windows-on b kill)’ never kills non-displayed buffers.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53870: calendar-exit doesn't kill calendar buffers
  2022-02-08  7:39                   ` bug#53870: calendar-exit doesn't kill calendar buffers Juri Linkov
@ 2022-02-09  8:32                     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 24+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-09  8:32 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 53870

Juri Linkov <juri@linkov.net> writes:

> The problem is that when the KILL arg of calendar-exit is non-nil,
> it still doesn't kill calendar buffers.

I've now fixed this in Emacs 29.

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  8:25                 ` Lars Ingebrigtsen
  2022-02-07 23:50                   ` Michael Heerdegen
@ 2022-02-09 18:03                   ` Francesco Potortì
  1 sibling, 0 replies; 24+ messages in thread
From: Francesco Potortì @ 2022-02-09 18:03 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Michael Heerdegen, 53764

Michael Heerdegen <michael_heerdegen@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.





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-07  9:28             ` Lars Ingebrigtsen
@ 2022-02-09 18:21               ` Francesco Potortì
  2022-02-09 21:26                 ` Andreas Schwab
  0 siblings, 1 reply; 24+ messages in thread
From: Francesco Potortì @ 2022-02-09 18:21 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-09 18:21               ` Francesco Potortì
@ 2022-02-09 21:26                 ` Andreas Schwab
  2022-02-09 21:52                   ` Francesco Potortì
  0 siblings, 1 reply; 24+ messages in thread
From: Andreas Schwab @ 2022-02-09 21:26 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: Lars Ingebrigtsen, 53764

On Feb 09 2022, Francesco Potortì wrote:

> 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?

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

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#53764: 27.1; shouldn't ~/diary be in diary-mode?
  2022-02-09 21:26                 ` Andreas Schwab
@ 2022-02-09 21:52                   ` Francesco Potortì
  0 siblings, 0 replies; 24+ messages in thread
From: Francesco Potortì @ 2022-02-09 21:52 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Lars Ingebrigtsen, 53764

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





^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-02-09 21:52 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 22:12 bug#53764: 27.1; shouldn't ~/diary be in diary-mode? Francesco Potortì
2022-02-05  6:54 ` Lars Ingebrigtsen
2022-02-05 15:02   ` Francesco Potortì
2022-02-05 21:54     ` Lars Ingebrigtsen
2022-02-05 23:11       ` Francesco Potortì
2022-02-06 23:07         ` Lars Ingebrigtsen
2022-02-07  0:39           ` Michael Heerdegen
2022-02-07  3:45             ` Lars Ingebrigtsen
2022-02-07  4:17               ` Michael Heerdegen
2022-02-07  8:25                 ` Lars Ingebrigtsen
2022-02-07 23:50                   ` Michael Heerdegen
2022-02-09 18:03                   ` Francesco Potortì
2022-02-07 19:39               ` Juri Linkov
2022-02-08  6:11                 ` Lars Ingebrigtsen
2022-02-08  7:39                   ` bug#53870: calendar-exit doesn't kill calendar buffers Juri Linkov
2022-02-09  8:32                     ` Lars Ingebrigtsen
2022-02-08  1:16             ` bug#53764: 27.1; shouldn't ~/diary be in diary-mode? Phil Sainty
2022-02-07  9:10           ` Francesco Potortì
2022-02-07  9:28             ` Lars Ingebrigtsen
2022-02-09 18:21               ` Francesco Potortì
2022-02-09 21:26                 ` Andreas Schwab
2022-02-09 21:52                   ` Francesco Potortì
2022-02-06  3:54       ` Michael Heerdegen
2022-02-07  5:08         ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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