emacs-devel
[Top][All Lists]
Advanced

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

Re: (local) abbrev injective and other problems, capitalization


From: Uwe Brauer
Subject: Re: (local) abbrev injective and other problems, capitalization
Date: Thu, 05 Jul 2018 12:15:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>>> "Stefan" == Stefan Monnier <address@hidden> writes:

   >> So it seems that :case-fixed is the solution.  But how do I use is for
   >> inverse-add-mode-abbrev and friends?

   > You'll need to tweak the code and/or write your own, I'm afraid.

Ok. I am not really using inverse-add-mode-abbrev but I use the abbrev
via flyspell. Flyspell allows you to insert a correction either in the
local (which is my case) or in the global abbrev table. 

I have even written a small package my own, which I might put some day
in MELPA, which generalise this mechanism to various languages. Most
likely this is not very elegant but for each language there exists a
minor mode with its associated local abbrev table (right now the package
contains 5 language but it could be generalised). The point which is a
bit delicate is, that if you switch one minor mode on, you have to make
sure that the others are off.

So here is a short example
(define-abbrev-table 'francais-minor-mode-abbrev-table '(        ;Version:1.2
     ("tx" "text" nil 0)
     ))

(defvar francais-minor-mode-syntax-table nil
  "Syntax table used while in francais  mode.")

(define-minor-mode francais-minor-mode  
    nil nil nil nil
    (setq local-abbrev-table
          (if francais-minor-mode
              francais-minor-mode-abbrev-table)))


And some function which are not relevant here.

In any case, the code most relevant here is the following 

(defun flyspell-define-abbrev (name expansion)
  (let ((table (flyspell-abbrev-table)))
    (when table
      (define-abbrev table (downcase name) expansion ))))


So first the phrase to be abbrev-expanded is downcased and then defined.


My first naive approach was this


(define-abbrev table (downcase name) expansion nil :case-fixed nil))))(defun 
flyspell-define-abbrev (name expansion)
  (let ((table (flyspell-abbrev-table)))
    (when table
      (define-abbrev table (downcase name) expansion nil :case-fixed nil))))

But it did not work.

I then tried 

(abbrev-table-put text-mode-abbrev-table :case-fixed t)

Or 
(abbrev-table-put francais-minor-mode-syntax-table :case-fixed t)

But it did not help. The problem described persisted. Any help would be
appreciate because right now I don't know where to start even.

Uwe 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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