improve spell button to toggle on and off

This commit is contained in:
2025-07-13 10:31:09 +02:00
parent 542ad44c34
commit 373aa8226e

View File

@@ -99,12 +99,14 @@
"Button to run `fill-region'.") "Button to run `fill-region'.")
(defun my-tool-bar-function-spell (event) (defun my-tool-bar-function-spell (event)
"Run `flyspell-buffer'." "Run `flyspell-mode' and `flyspell-buffer'."
(interactive "e") (interactive "e")
(let () (if flyspell-mode
(flyspell-buffer))) (flyspell-mode -1)
(flyspell-mode 1) ;; local on-the-fly
(flyspell-buffer) )) ;; whole buffer
(defvar my-tool-bar-button-spell "Spell " (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 () (defun my-langtool-active-p ()
"Check if `langtool-check-buffer' is active." "Check if `langtool-check-buffer' is active."
@@ -135,45 +137,45 @@ You can hide these buttons by customizing `tab-bar-format' and removing
(save (save
menu-item ,my-tool-bar-button-save my-tool-bar-function-save menu-item ,my-tool-bar-button-save my-tool-bar-function-save
;; :enable buffer-modified-p ;; :enable buffer-modified-p
:help "Save `save-buffer'") :help "Save / `save-buffer'")
;;(sep-test menu-item "" ignore) ;;(sep-test menu-item "" ignore)
(open (open
menu-item ,my-tool-bar-button-open my-tool-bar-function-open menu-item ,my-tool-bar-button-open my-tool-bar-function-open
:help "Open File... `find-file'") :help "Open File... / `find-file'")
(cancle (cancle
menu-item ,my-tool-bar-button-cancle my-tool-bar-function-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) (sep-1 menu-item ,(tab-bar-separator) ignore)
(revert (revert
menu-item ,my-tool-bar-button-revert my-tool-bar-function-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 (undo
menu-item ,my-tool-bar-button-undo my-tool-bar-function-undo menu-item ,my-tool-bar-button-undo my-tool-bar-function-undo
:help "Undo `undo-only'") :help "Undo / `undo-only'")
(redo (redo
menu-item ,my-tool-bar-button-redo my-tool-bar-function-redo menu-item ,my-tool-bar-button-redo my-tool-bar-function-redo
:help "Redo `undo-redo'") :help "Redo / `undo-redo'")
(cut (cut
menu-item ,my-tool-bar-button-cut my-tool-bar-function-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 (copy
menu-item ,my-tool-bar-button-copy my-tool-bar-function-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 (paste
menu-item ,my-tool-bar-button-paste my-tool-bar-function-paste menu-item ,my-tool-bar-button-paste my-tool-bar-function-paste
:help "Paste text `yank'") :help "Paste text / `yank'")
(fill (fill
menu-item ,my-tool-bar-button-fill my-tool-bar-function-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 ,(tab-bar-separator) ignore)
;; (sep-2 menu-item ,my-tool-bar-separator ignore ;; (sep-2 menu-item ,my-tool-bar-separator ignore
;; :enable nil :help "") ;; :enable nil :help "")
(spell (spell
menu-item ,my-tool-bar-button-spell my-tool-bar-function-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 (langtool
menu-item ,my-tool-bar-button-langtool my-tool-bar-function-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)))) (sep-tool-bar menu-item ,(my-tool-bar-newline) ignore))))
(defun my-tool-bar--load-buttons () (defun my-tool-bar--load-buttons ()