[Top][All Lists]

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

Re: Abbrev suggestions - feedback appreciated

From: Eli Zaretskii
Subject: Re: Abbrev suggestions - feedback appreciated
Date: Sat, 16 Sep 2017 11:46:02 +0300

> From: Mathias Dahl <address@hidden>
> Date: Sat, 16 Sep 2017 09:51:53 +0200
> Some days back I was typing away in Emacs and after typing some hard to
> spell word I realized that I probably had an abbrev defined for that
> word. I checked by abbrev definitions and, yes, it was there. It turns
> out I had many defined abbrevs that I had forgotten about, so I was
> typing more than I needed. This got me thinking that it would be nice if
> Emacs could tell me when I have typed a word that exists as an abbrev
> expansion. After some research in abbrev.el I finally got something to
> work, and you can find it below.
> I would like to have people's comments on the idea, and know if this
> might allredy exist (I tried to find something similar but couldn't), and
> also if there are any performance problems or other in my code. The
> internals of abbrevs are dark and mysterious to me, so I might miss some
> crucial things. But, the code seems to do what I want it to.
> Also, if people like this idea, perhaps it could be added to Emacs
> proper. Surely it can live on its life as a separate library on Melpa,
> Elpa or other place, but the code is quite short and this feels like
> something that could be a simple option/toggle in Emacs standard abbrev
> functionality. I have papers in place if this is something people would
> like.

Why not add this as an optional feature to abbrev.el, conditional on
some defcustom?

> (defun absug-maybe-suggest ()
>   "Suggest an abbrev to the user based on the word before point."
>   (let* ((word (absug-word-before-point))
>          (expansions (absug-get-active-abbrev-expansions))
>          (abbrev (assoc word expansions)))
>     (if abbrev
>         (message "Abbrev suggestion: The word `%s' has the abbrev
> `%s' defined" (car abbrev) (cdr abbrev)))))

I'd suggest to make the message text shorter, to make the probability
of its becoming longer than the echo-area width, which would resize
the mini-window and cause an annoying redisplay.  I'd just drop the
part before the colon, as the rest already says there is an abbrev.


reply via email to

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