* abbrev-expand-functions
@ 2009-03-04 15:22 Leo
2009-03-13 11:27 ` abbrev-expand-functions Leo
0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2009-03-04 15:22 UTC (permalink / raw)
To: help-gnu-emacs
Hi there,
I want to include a function in abbrev-expand-functions that does
post-processing the expansion, however I'd like to avoid inserting the
character that triggers it. For example, if <SPC> triggers an abbrev,
that function will be called to process the expansion but <SPC> should
be not be inserted.
But according to the manual, it seems this is only possible by defining
the abbreviation with a 'no-self-insert hook. This is not an option to
me as I want my function to be general for all abbreviations.
Any idea how to get this done?
p.s.
I read the source of expand-abbrev to find out how the hook
work. Unfortunately it is written with lables and lexical-let that I yet
to familiarise myself with.
Thanks,
--
.: Leo :. [ sdl.web AT gmail.com ] .: I use Emacs :.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev-expand-functions
2009-03-04 15:22 abbrev-expand-functions Leo
@ 2009-03-13 11:27 ` Leo
2009-03-13 20:24 ` abbrev-expand-functions Johan Bockgård
0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2009-03-13 11:27 UTC (permalink / raw)
To: help-gnu-emacs
On 2009-03-04 15:22 +0000, Leo wrote:
> But according to the manual, it seems this is only possible by defining
> the abbreviation with a 'no-self-insert hook. This is not an option to
> me as I want my function to be general for all abbreviations.
>
> Any idea how to get this done?
Any elisp gurus that can offer some help to question? Thank you.
--
.: Leo :. [ sdl.web AT gmail.com ] .: I use Emacs :.
www.git-scm.com
git - the one true version control system
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev-expand-functions
2009-03-13 11:27 ` abbrev-expand-functions Leo
@ 2009-03-13 20:24 ` Johan Bockgård
2009-03-15 13:05 ` abbrev-expand-functions Leo
0 siblings, 1 reply; 6+ messages in thread
From: Johan Bockgård @ 2009-03-13 20:24 UTC (permalink / raw)
To: help-gnu-emacs
Leo <sdl.web@gmail.com> writes:
> On 2009-03-04 15:22 +0000, Leo wrote:
>> But according to the manual, it seems this is only possible by defining
>> the abbreviation with a 'no-self-insert hook. This is not an option to
>> me as I want my function to be general for all abbreviations.
>>
>> Any idea how to get this done?
>
> Any elisp gurus that can offer some help to question? Thank you.
;;; For Emacs 23
(fset 'my-no-self-insert 'my-no-self-insert-hook)
(put 'my-no-self-insert-hook 'no-self-insert t)
(defun my-abbrev-expand-function (expander)
(and
;; The normal expansion.
(funcall expander)
;; Return a symbol whose symbol-function has a non-nil
;; `no-self-insert' property.
'my-no-self-insert))
(add-hook 'abbrev-expand-functions 'my-abbrev-expand-function)
Note that no-self-insert interacts strangely with RET.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev-expand-functions
2009-03-13 20:24 ` abbrev-expand-functions Johan Bockgård
@ 2009-03-15 13:05 ` Leo
2009-03-15 16:34 ` abbrev-expand-functions Johan Bockgård
0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2009-03-15 13:05 UTC (permalink / raw)
To: help-gnu-emacs
On 2009-03-13 20:24 +0000, Johan Bockgård wrote:
> Leo <sdl.web@gmail.com> writes:
>
>> On 2009-03-04 15:22 +0000, Leo wrote:
>>> But according to the manual, it seems this is only possible by defining
>>> the abbreviation with a 'no-self-insert hook. This is not an option to
>>> me as I want my function to be general for all abbreviations.
>>>
>>> Any idea how to get this done?
>>
>> Any elisp gurus that can offer some help to question? Thank you.
>
> ;;; For Emacs 23
>
> (fset 'my-no-self-insert 'my-no-self-insert-hook)
> (put 'my-no-self-insert-hook 'no-self-insert t)
>
> (defun my-abbrev-expand-function (expander)
> (and
> ;; The normal expansion.
> (funcall expander)
> ;; Return a symbol whose symbol-function has a non-nil
> ;; `no-self-insert' property.
> 'my-no-self-insert))
>
> (add-hook 'abbrev-expand-functions 'my-abbrev-expand-function)
>
>
> Note that no-self-insert interacts strangely with RET.
This is brilliant!
Since the return value has a symbol-function, how is that
symbol-function being used in abbrev? I am asking this in hope to
understand better the consequences of setting it to a real function.
Is the following understanding correct?
Internally, each abbrev symbol is like an uninterned variable with a
structure like this:
(ABBREVNAME EXPANSION [HOOK] [PROPS...])
the symbol's each property maps to a slot in that structure, for
example, symbol-function maps to [HOOK] etc.
If the above is correct, where to find an exhaustive list of these
mappings? This will allow me to adjust other properties that may come up
in future.
Thank you very much.
--
.: Leo :. [ sdl.web AT gmail.com ] .: I use Emacs :.
www.git-scm.com
git - the one true version control system
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev-expand-functions
2009-03-15 13:05 ` abbrev-expand-functions Leo
@ 2009-03-15 16:34 ` Johan Bockgård
2009-03-15 19:41 ` abbrev-expand-functions Leo
0 siblings, 1 reply; 6+ messages in thread
From: Johan Bockgård @ 2009-03-15 16:34 UTC (permalink / raw)
To: help-gnu-emacs
Leo <sdl.web@gmail.com> writes:
> Is the following understanding correct?
>
> Internally, each abbrev symbol is like an uninterned variable with a
> structure like this:
The abbrev symbol is interned in the abbrev TABLE.
> (ABBREVNAME EXPANSION [HOOK] [PROPS...])
>
> the symbol's each property maps to a slot in that structure, for
> example, symbol-function maps to [HOOK] etc.
More or less.
"An abbrev table is represented as an obarray containing a symbol for
each abbreviation. The symbol's name is the abbreviation; its value
is the expansion; its function definition is the hook function to do
the expansion; its property list cell typically contains various
additional properties such as the use count, the number of times the
abbreviation has been expanded, or whether the abbrev is a so-called
"system" abbrev defined by a major mode rather than by the user."
(info "(elisp) Abbrevs")
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev-expand-functions
2009-03-15 16:34 ` abbrev-expand-functions Johan Bockgård
@ 2009-03-15 19:41 ` Leo
0 siblings, 0 replies; 6+ messages in thread
From: Leo @ 2009-03-15 19:41 UTC (permalink / raw)
To: help-gnu-emacs
On 2009-03-15 16:34 +0000, Johan Bockgård wrote:
> More or less.
>
> "An abbrev table is represented as an obarray containing a symbol for
> each abbreviation. The symbol's name is the abbreviation; its value
> is the expansion; its function definition is the hook function to do
> the expansion; its property list cell typically contains various
> additional properties such as the use count, the number of times the
> abbreviation has been expanded, or whether the abbrev is a so-called
> "system" abbrev defined by a major mode rather than by the user."
>
> (info "(elisp) Abbrevs")
Ah, I have missed this critical information several times. Thank you. I
think I have a better picture of abbrev now.
Regards,
--
.: Leo :. [ sdl.web AT gmail.com ] .: I use Emacs :.
www.git-scm.com
git - the one true version control system
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-03-15 19:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-04 15:22 abbrev-expand-functions Leo
2009-03-13 11:27 ` abbrev-expand-functions Leo
2009-03-13 20:24 ` abbrev-expand-functions Johan Bockgård
2009-03-15 13:05 ` abbrev-expand-functions Leo
2009-03-15 16:34 ` abbrev-expand-functions Johan Bockgård
2009-03-15 19:41 ` abbrev-expand-functions Leo
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).