From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Abbrev suggestions - feedback appreciated Date: Sat, 16 Sep 2017 11:46:02 +0300 Message-ID: <83efr7kp4l.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1505551593 4235 195.159.176.226 (16 Sep 2017 08:46:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 16 Sep 2017 08:46:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: Mathias Dahl Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 16 10:46:26 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dt8k4-0000rF-Ng for ged-emacs-devel@m.gmane.org; Sat, 16 Sep 2017 10:46:24 +0200 Original-Received: from localhost ([::1]:56426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dt8kB-0006Cv-PQ for ged-emacs-devel@m.gmane.org; Sat, 16 Sep 2017 04:46:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dt8jf-0006Ck-GN for emacs-devel@gnu.org; Sat, 16 Sep 2017 04:46:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dt8jc-0004cH-9R for emacs-devel@gnu.org; Sat, 16 Sep 2017 04:45:59 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60691) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dt8jc-0004c5-67; Sat, 16 Sep 2017 04:45:56 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4841 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dt8jb-0001w2-6a; Sat, 16 Sep 2017 04:45:55 -0400 In-reply-to: (message from Mathias Dahl on Sat, 16 Sep 2017 09:51:53 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218349 Archived-At: > From: Mathias Dahl > 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. Thanks.