* pre-abbrev-expand-hook
@ 2004-07-02 22:44 Roland Winkler t28834
2004-07-05 14:22 ` pre-abbrev-expand-hook Richard Stallman
0 siblings, 1 reply; 2+ messages in thread
From: Roland Winkler t28834 @ 2004-07-02 22:44 UTC (permalink / raw)
This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.
Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.
In GNU Emacs 21.2.1 (i386-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2002-04-09 on tfkp12
configured using `configure --prefix=/nfs/common --libexecdir=/nfs/common/lib --bindir=/nfs/common/lib/emacs/21.2/bin/i686-Linux --mandir=/nfs/common/share/man --infodir=/nfs/common/share/info --with-gcc --with-pop --with-x --with-x-toolkit=athena i386-pc-linux'
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: POSIX
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_US
locale-coding-system: iso-latin-1
default-enable-multibyte-characters: t
Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:
The following code is taken from the elisp manual, node Abbrev Expansion
(add-hook 'pre-abbrev-expand-hook 'query-if-not-space)
;; This is the function invoked by `pre-abbrev-expand-hook'.
;; If the user terminated the abbrev with a space, the function does
;; nothing (that is, it returns so that the abbrev can expand). If the
;; user entered some other character, this function asks whether
;; expansion should continue.
;; If the user answers the prompt with `y', the function returns
;; `nil' (because of the `not' function), but that is
;; acceptable; the return value has no effect on expansion.
(defun query-if-not-space ()
(if (/= ?\ (preceding-char))
(if (not (y-or-n-p "Do you want to expand this abbrev? "))
(error "Not expanding this abbrev"))))
Somehow this example doesn't work for me. preceding-char in
query-if-not-space should return the word-separator character which
will cause the abbrev expansion. However, preceding-char returns the
last character of the abbreviation to be expanded.
I looked into this because I wanted to write a function that will
control abbrev expansion based on the word separator character that
invoked the abbrev axpansion. The above example from the elisp manual
suggests that this should be possible. But somehow it doesn't work.
Same problem with more recent versions of emacs.
Am I missing something here?
Roland
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: pre-abbrev-expand-hook
2004-07-02 22:44 pre-abbrev-expand-hook Roland Winkler t28834
@ 2004-07-05 14:22 ` Richard Stallman
0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2004-07-05 14:22 UTC (permalink / raw)
Cc: bug-gnu-emacs
The example was no good; it should test last-command-char rather
that (preceding-char).
I discovered that pre-abbrev-expand-hook is useless with the current
C code, since it is run whether or not the previous word
is an abbrev. This change seems to make it usable.
*** abbrev.c 17 Jun 2004 19:28:38 -0400 1.62
--- abbrev.c 05 Jul 2004 01:52:09 -0400
***************
*** 248,255 ****
value = Qnil;
- Frun_hooks (1, &Qpre_abbrev_expand_hook);
-
wordstart = 0;
if (!(BUFFERP (Vabbrev_start_location_buffer)
&& XBUFFER (Vabbrev_start_location_buffer) == current_buffer))
--- 248,253 ----
***************
*** 325,330 ****
--- 323,330 ----
wordend - wordstart, p - buffer);
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
return value;
+
+ Frun_hooks (1, &Qpre_abbrev_expand_hook);
if (INTERACTIVE && !EQ (minibuf_window, selected_window))
{
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-05 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-02 22:44 pre-abbrev-expand-hook Roland Winkler t28834
2004-07-05 14:22 ` pre-abbrev-expand-hook 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).