unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1110: 23.0.60; please provide a hook after ispell-change-dictionary
@ 2008-10-07 14:55 Stefano Zacchiroli
  2019-06-20 19:09 ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Stefano Zacchiroli @ 2008-10-07 14:55 UTC (permalink / raw)
  To: emacs-pretest-bug; +Cc: Ken Stevens

As per subject: please provide a hook to which function can be
registered to execute actions after ispell dictionary gets changed.

FWIW, my use case is in the combination with flyspell. When using
that, if you have a spelled buffer, you want to re-spell it (using
"flyspell-buffer") as soon as you change the dictionary. Having the
required hook would enable doing so in a more clean way wrt advising.


In GNU Emacs 23.0.60.1 (x86_64-pc-linux-gnu, GTK+ Version 2.12.11)
 of 2008-10-05 on elegiac, modified by Debian
 (emacs-snapshot package, version 1:20081005-1)
Windowing system distributor `The X.Org Foundation', version 11.0.10402000
configured using `configure  '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/23.0.60/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.0.60/site-lisp:/usr/share/emacs/site-lisp' '--with-x=yes' '--with-x-toolkit=gtk' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: it_IT.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  iswitchb-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
x j x j x j x j d d k o i <return> <backspace> <backspace> 
<return> D o e s SPC t h i s SPC b l i n k g SPC s 
o m e l i <C-backspace> <backspace> <backspace> SPC 
s o m e l i g <backspace> <backspace> <backspace> SPC 
l i g h t ? S-SPC ( O r SPC m a y b e SPC s h o <backspace> 
<backspace> <backspace> e x p l a i n s SPC t h a t 
SPC t <backspace> t h e SPC b u g SPC i s SPC n o t 
SPC a SPC t <backspace> <backspace> t SPC a l l SPC 
r e l a t e d SPC t o SPC i <backspace> V i p e r SPC 
a n d SPC n e e d SPC t o SPC b e SPC l o o k e d SPC 
f o r SPC i n SPC s o m e SPC e m a c s c l i e n t 
SPC d e t a i l ? ) M-q <escape> o <return> T h a n 
k s SPC a SPC l o t ! <return> C h e e r s . <escape> 
g g C-x # y C-h f i s p e l l - c h a <tab> <return> 
<help-echo> <help-echo> <help-echo> <help-echo> <down-mouse-1> 
<mouse-2> M-< C-s i s p e l l - c h a n g e - d i c 
t i o n a r y C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s <return> M-< C-x o M-x r e p o <tab> r 
t - e m <tab> <return>

Recent messages:
Mark activated
Save file /tmp/mutt-usha-1000-20151-2? (y or n) 
Wrote /tmp/mutt-usha-1000-20151-2
Type C-x 1 to delete the help window.
uncompressing ispell.el.gz...done
Note: file is write protected
Mark set
Mark saved where search started
Mark set
Making completion list...






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#1110: 23.0.60; please provide a hook after ispell-change-dictionary
  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
  2019-06-27 18:03   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2019-06-20 19:09 UTC (permalink / raw)
  To: 1110; +Cc: zack

[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#1110: 23.0.60; please provide a hook after ispell-change-dictionary
  2019-06-20 19:09 ` Stefan Kangas
@ 2019-06-27 18:03   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-27 18:03 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 1110, zack

Stefan Kangas <stefan@marxist.se> writes:

> 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.

Looks good; I've now applied it to the Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-27 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-06-27 18:03   ` Lars Ingebrigtsen

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).