Project

General

Profile

Bug #460

Emacs UI: updating abbrev-table

Added by John Abbott about 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Category:
EmacsUI
Target version:
Start date:
09 Mar 2014
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

I changed my cocoa5.el file and was surprised to find that some keywords which have now been removed were still recognized (and "expanded") by Emacs.

The problem seems to be that at some point I told Emacs to save its abbrevs (in file $HOME/.abbrev_defs), and that these abbrevs are automatically loaded (after the new cocoa5-mode definitions).

How to fix this?

2014-04 conclusion: it does not seem to be possible to avoid "some" automatic saving, but all-or-nothing. So we set it for "no-auto-save" in cocoa5.emacs (the file for "Preferences"). Anyway capitalization is no longer necessary and now can be disabled (see #523)


Related issues

Related to CoCoA-5 - Feature #523: EmacsUI: lower case keywordsClosed2014-04-04

History

#1 Updated by John Abbott about 10 years ago

One possible solution is to forcibly load the .abbrev_defs file before loading cocoa5 mode. I believe thsi can be done with the following lines, perhaps at the start of the .emacs file:

;; forcibly read abbrev-file *before* reading CoCoA mode
(if (file-exists-p abbrev-file-name)
    (quietly-read-abbrev-file))

A quick test suggests that this does not work, or at least not as I would like (e.g. Lambda is still recognized as a keyword even though my current cocoa5.el does not declare it).

The file .abbrev_defs may contain abbrevs from other modes so we cannot simply delete it (e.g. if it is older than cocoa5.el). Probably the correct way to update it is to read it, overwrite the "old" cocoa5-abbrev-table and then save all abbrevs in .abbrev_defs. It seems a bit wasteful to do this every time.

I also note that even if .abbrev_defs is newer than cocoa5.el that gives no guarantee that cocoa5-abbrev-table is up-to-date, as some other abbrev table may have been updated after cocoa5-abbrev-table was saved.

What to do? Since cocoa5.el redefines the abbrev table whenever it is loaded, the simplest would simply be to say not to save cocoa5-abbrev-table; can this be done? Perhaps abbrev tables are not the right way to implement this?

I noticed the problem because emacs kept on converting not into Not which is decidedly counter-productive now that not is no longer a keyword (and that the function is called not).

#2 Updated by John Abbott about 10 years ago

One post I read suggested that cocoa5-abbrev-table should be cocoa5-mode-abbrev-table. Investigate and decide.

#3 Updated by Anna Maria Bigatti about 10 years ago

John Abbott wrote:

One post I read suggested that cocoa5-abbrev-table should be cocoa5-mode-abbrev-table. Investigate and decide.

yes, I agree.
I see that I have many things in my "~/abbrev_defs" file (I didn't even know it existed, gosh), and they are all called "blah-mode-abbrev-table"

#4 Updated by Anna Maria Bigatti about 10 years ago

  • Status changed from New to In Progress

John Abbott wrote:

A quick test suggests that this does not work, or at least not as I would like (e.g. Lambda is still recognized as a keyword even though my current cocoa5.el does not declare it).

.abbrev_defs is updated, and not replaced :-/

But I found this works (a bit of an overkill?) when placed in the cocoa5.emacs file.
(the "Preferences" file). I deleted the table from .abbrev_defs and it was not refilled.

;; DO NOT save abbrev table
(setq save-abbrevs nil)

Since expert emacs users are supposed to read and edit this file if they do not like some options, I think that is a good place. (cvs-ed)
We should set that before changing the name of the table so that the old saved tables will just become unused ;-) and the new one will not be saved.

I also found this topic is worth investigating, but I'm too tired now, so I'll leave this note: http://www.emacswiki.org/emacs/AbbrevMode#toc5 (Using Abbrevs in Code Only)

#5 Updated by John Abbott about 10 years ago

  • % Done changed from 0 to 20

Somehow we'll have to tell those who have created .abbrev_defs to remove it (or edit it to remove the cocoa5-abbrev-table).

It does seem odd that you cannot simply say "don't save this abbrev table"...

#6 Updated by Anna Maria Bigatti about 10 years ago

John Abbott wrote:

Somehow we'll have to tell those who have created .abbrev_defs to remove it (or edit it to remove the cocoa5-abbrev-table).

should not be needed since we change the name into cocoa5-mode-..

[ note 20140319 JAA: but the "junk" will remain in their .abbrev_defs file]

It does seem odd that you cannot simply say "don't save this abbrev table"...

Maybe you can, but some emacs-geek user might want to save his own additions to the cocoa5 table. So we cannot protect every user. So the safest option for both experts and non-experts is to prevent automatic saving of the abbrev file.

#7 Updated by Anna Maria Bigatti about 10 years ago

  • Target version set to CoCoA-5.1.0 Easter14

#8 Updated by Anna Maria Bigatti about 10 years ago

  • Status changed from In Progress to Feedback
  • Assignee set to Anna Maria Bigatti
  • % Done changed from 20 to 90

#9 Updated by John Abbott almost 10 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

It seems to work well enough (at least most of the time).
Closing!

Also available in: Atom PDF