From 373aa8226e401f99b4207bf6f6343923dc668bb6 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sun, 13 Jul 2025 10:31:09 +0200 Subject: [PATCH] improve spell button to toggle on and off --- lisp/my/my-tool-bar.el | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lisp/my/my-tool-bar.el b/lisp/my/my-tool-bar.el index ea64e89f..524d117e 100644 --- a/lisp/my/my-tool-bar.el +++ b/lisp/my/my-tool-bar.el @@ -99,12 +99,14 @@ "Button to run `fill-region'.") (defun my-tool-bar-function-spell (event) - "Run `flyspell-buffer'." + "Run `flyspell-mode' and `flyspell-buffer'." (interactive "e") - (let () - (flyspell-buffer))) + (if flyspell-mode + (flyspell-mode -1) + (flyspell-mode 1) ;; local on-the-fly + (flyspell-buffer) )) ;; whole buffer (defvar my-tool-bar-button-spell "Spell " - "Button to run `flyspell-buffer'.") + "Button to run `flyspell-mode' and `flyspell-buffer'.") (defun my-langtool-active-p () "Check if `langtool-check-buffer' is active." @@ -135,45 +137,45 @@ You can hide these buttons by customizing `tab-bar-format' and removing (save menu-item ,my-tool-bar-button-save my-tool-bar-function-save ;; :enable buffer-modified-p - :help "Save `save-buffer'") + :help "Save / `save-buffer'") ;;(sep-test menu-item "" ignore) (open menu-item ,my-tool-bar-button-open my-tool-bar-function-open - :help "Open File... `find-file'") + :help "Open File... / `find-file'") (cancle menu-item ,my-tool-bar-button-cancle my-tool-bar-function-cancle - :help "Cancle `keyboard-escape-quit'") + :help "Cancle / `keyboard-escape-quit'") (sep-1 menu-item ,(tab-bar-separator) ignore) (revert menu-item ,my-tool-bar-button-revert my-tool-bar-function-revert - :help "Re-read current buffer from its file `revert-buffer'") + :help "Re-read current buffer from its file / `revert-buffer'") (undo menu-item ,my-tool-bar-button-undo my-tool-bar-function-undo - :help "Undo `undo-only'") + :help "Undo / `undo-only'") (redo menu-item ,my-tool-bar-button-redo my-tool-bar-function-redo - :help "Redo `undo-redo'") + :help "Redo / `undo-redo'") (cut menu-item ,my-tool-bar-button-cut my-tool-bar-function-cut - :help "Cut text of region `kill-region'") + :help "Cut text of region / `kill-region'") (copy menu-item ,my-tool-bar-button-copy my-tool-bar-function-copy - :help "Copy text of region `kill-ring-save'") + :help "Copy text of region / `kill-ring-save'") (paste menu-item ,my-tool-bar-button-paste my-tool-bar-function-paste - :help "Paste text `yank'") + :help "Paste text / `yank'") (fill menu-item ,my-tool-bar-button-fill my-tool-bar-function-fill - :help "Fill text in region to fit between left and right margin `fill-region'") + :help "Fill text in region to fit between left and right margin / `fill-region'") (sep-2 menu-item ,(tab-bar-separator) ignore) ;; (sep-2 menu-item ,my-tool-bar-separator ignore ;; :enable nil :help "") (spell menu-item ,my-tool-bar-button-spell my-tool-bar-function-spell - :help "Spell `flyspell-buffer'") + :help "Spell checking / `flyspell-mode' and `flyspell-buffer'") (langtool menu-item ,my-tool-bar-button-langtool my-tool-bar-function-langtool - :help "languagetool `langtool-check-buffer'") + :help "LanguageTool / `langtool-check-buffer'") (sep-tool-bar menu-item ,(my-tool-bar-newline) ignore)))) (defun my-tool-bar--load-buttons ()