unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: 1110@debbugs.gnu.org
Cc: zack@upsilon.cc
Subject: bug#1110: 23.0.60; please provide a hook after ispell-change-dictionary
Date: Thu, 20 Jun 2019 21:09:31 +0200	[thread overview]
Message-ID: <CADwFkmkZq0PkTW56z8ZS3tg+2o2bgsnggPZqR4CMFoXpLYHXBA@mail.gmail.com> (raw)
In-Reply-To: <20081007145524.C44C06052@usha.takhisis.invalid>

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

tags 1110 + patch
quit

zack@upsilon.cc (Stefano Zacchiroli) writes:
> As per subject: please provide a hook to which function can be
> registered to execute actions after ispell dictionary gets changed.

I wrote this up; see attached patch.

Not sure if this should be announced in NEWS, but I included an entry
for good measure.

Thanks,
Stefan Kangas

[-- Attachment #2: 0001-Add-new-ispell-change-dictionary-hook-Bug-1110.patch --]
[-- Type: application/octet-stream, Size: 2393 bytes --]

From 5b3799a6ddc73bbe48bfa50c10a378d70818e093 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Thu, 20 Jun 2019 20:49:51 +0200
Subject: [PATCH] Add new ispell-change-dictionary-hook (Bug#1110)

* lisp/textmodes/ispell.el (ispell-change-dictionary-hook): New hook.
(ispell-change-dictionary): Call new hook.
---
 etc/NEWS                 | 8 ++++++++
 lisp/textmodes/ispell.el | 9 +++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index e3023216ac..ff25b76199 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1523,6 +1523,14 @@ buffer periodically when 'auto-revert-avoid-polling' is non-nil.
 *** 'bookmark-file' and 'bookmark-old-default-file' are now obsolete
 aliases of 'bookmark-default-file'.
 
+** Ispell
+
+---
+*** New hook 'ispell-change-dictionary-hook'.
+This runs after changing the dictionary and could be used to
+automatically spellcheck a buffer when changing language without
+needing to advice 'ispell-change-dictionary'.
+
 \f
 * New Modes and Packages in Emacs 27.1
 
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index d488c05418..9dfa9f3c44 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2973,6 +2973,9 @@ ispell-kill-ispell
     (message "Ispell process killed")
     nil))
 
+(defvar ispell-change-dictionary-hook nil
+  "Hook run after changing dictionary.")
+
 ;; ispell-change-dictionary is set in some people's hooks.  Maybe this should
 ;;  call ispell-init-process rather than wait for a spell checking command?
 
@@ -2998,7 +3001,8 @@ ispell-change-dictionary
 	 (ispell-internal-change-dictionary)
 	 (message "Using %s dictionary"
 		  (or (and (not arg) ispell-local-dictionary)
-		      ispell-dictionary "default")))
+		      ispell-dictionary "default"))
+         (run-hooks 'ispell-change-dictionary-hook))
 	((equal dict (or (and (not arg) ispell-local-dictionary)
 			 ispell-dictionary "default"))
 	 ;; Specified dictionary is the default already. Could reload
@@ -3020,7 +3024,8 @@ ispell-change-dictionary
 	 (setq ispell-buffer-session-localwords nil)
 	 (message "%s Ispell dictionary set to %s"
 		  (if arg "Global" "Local")
-		  dict))))
+		  dict)
+         (run-hooks 'ispell-change-dictionary-hook))))
 
 (defun ispell-internal-change-dictionary ()
   "Update the dictionary and the personal dictionary used by Ispell.
-- 
2.21.0


  reply	other threads:[~2019-06-20 19:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-07 14:55 bug#1110: 23.0.60; please provide a hook after ispell-change-dictionary Stefano Zacchiroli
2019-06-20 19:09 ` Stefan Kangas [this message]
2019-06-27 18:03   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADwFkmkZq0PkTW56z8ZS3tg+2o2bgsnggPZqR4CMFoXpLYHXBA@mail.gmail.com \
    --to=stefan@marxist.se \
    --cc=1110@debbugs.gnu.org \
    --cc=zack@upsilon.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).