add buttons and functions to tool-bar

This commit is contained in:
2025-11-23 14:50:02 +01:00
parent ece5eadffe
commit 14ba373378
3 changed files with 130 additions and 37 deletions

View File

@@ -129,16 +129,28 @@
(comment-or-uncomment-region (region-beginning) (region-end)) (comment-or-uncomment-region (region-beginning) (region-end))
;; (comment-dwim) ;; (comment-dwim)
)) ))
(defvar my-tool-bar-button-fill "Comment " (defvar my-tool-bar-button-comment "Comment "
"Button to run `comment-or-uncomment-region'.") "Button to run `comment-or-uncomment-region'.")
(defun my-tool-bar-function-hide (event) (defun my-hide-elements ()
"Run `my-org-hide'." "."
(interactive "e") (interactive "e")
(let () (let ()
(my-org-hide) )) (pcase major-mode
(defvar my-tool-bar-button-fill "(Un)hide " ('org-mode
"Button to run `my-org-hide'.") (let ()
(my-org-toggle-elements)
))
(_ (message "%s: %s" "not defined for this major-mode"
major-mode)) )
))
(defun my-tool-bar-function-hide (event)
"Run `my-hide-elements' inside org-mode."
(interactive "e")
(let ()
(my-hide-elements)))
(defvar my-tool-bar-button-hide "(Un)hide "
"Button to run `my-hide-elements' inside org-mode.")
(defun my-tool-bar-function-spell (event) (defun my-tool-bar-function-spell (event)
"Run `flyspell-mode' and `flyspell-buffer'." "Run `flyspell-mode' and `flyspell-buffer'."
@@ -164,6 +176,25 @@
(defvar my-tool-bar-button-langtool "langtool " (defvar my-tool-bar-button-langtool "langtool "
"Button to run `langtool-check-buffer'.") "Button to run `langtool-check-buffer'.")
(defun my-tool-bar-function-play (event)
"Run `C-c'."
(interactive "e")
(let ()
(pcase major-mode
('org-mode (org-ctrl-c-ctrl-c))
(_ (message "%s: %s" "not defined for this major-mode"
major-mode)) )))
(defvar my-tool-bar-button-play "Cc "
"Button to run `C-c'.")
(defun my-tool-bar-function-read (event)
"Run `my-distraction-free'."
(interactive "e")
(let ()
(my-distraction-free) ))
(defvar my-tool-bar-button-read "Rdv "
"Button to run `my-distraction-free'.")
;; (defun my-tool-bar-format-save () ;; (defun my-tool-bar-format-save ()
;; "Produce the Menu button for the tool bar that shows the menu bar." ;; "Produce the Menu button for the tool bar that shows the menu bar."
;; `((menu-bar menu-item ,my-tool-bar-button-save ;; `((menu-bar menu-item ,my-tool-bar-button-save
@@ -217,7 +248,8 @@ You can hide these buttons by customizing `tab-bar-format' and removing
(propertize "`revert-buffer'" (propertize "`revert-buffer'"
'face 'font-lock-constant-face))) 'face 'font-lock-constant-face)))
(sep-1 menu-item ,(tab-bar-separator) ignore) ;; (sep-1 menu-item ,(tab-bar-separator) ignore)
(sep-1 menu-item " " ignore :enable nil :help "")
(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
@@ -254,15 +286,16 @@ You can hide these buttons by customizing `tab-bar-format' and removing
:help (concat "Comment text in region " :help (concat "Comment text in region "
(propertize "`comment-or-uncomment-region'" (propertize "`comment-or-uncomment-region'"
'face 'font-lock-constant-face))) 'face 'font-lock-constant-face)))
(comment (play
menu-item ,my-tool-bar-button-hide my-tool-bar-function-hide menu-item ,my-tool-bar-button-play my-tool-bar-function-play
:help (concat "(Un)hide elements " :help (concat "Run "
(propertize "`my-org-hide'" (propertize "`C-c'"
'face 'font-lock-constant-face))) 'face 'font-lock-constant-face)))
(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 "")
(sep-2 menu-item " " ignore :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
@@ -274,12 +307,28 @@ You can hide these buttons by customizing `tab-bar-format' and removing
:help (concat "LanguageTool " :help (concat "LanguageTool "
(propertize "`langtool-check-buffer'" (propertize "`langtool-check-buffer'"
'face 'font-lock-constant-face))) 'face 'font-lock-constant-face)))
(sep-tool-bar menu-item ,(my-tool-bar-newline) ignore)))) (hide
menu-item ,my-tool-bar-button-hide my-tool-bar-function-hide
:help (concat "(Un)hide elements "
(propertize "`my-hide-elements'"
'face 'font-lock-constant-face)))
(read
menu-item ,my-tool-bar-button-read my-tool-bar-function-read
:help (concat "Read view "
(propertize "`my-distraction-free'"
'face 'font-lock-constant-face)))
(sep-tool-bar menu-item ,(my-tool-bar-newline) ignore)
)))
(defun my-tool-bar--load-buttons () (defun my-tool-bar--load-buttons ()
"Load the icons for the tool bar buttons. "Load the icons for the tool bar buttons.
See `image-load-path' for possible locations for images. See `image-load-path' for possible locations for images.
See `icon-preference' for the order of type preference." See `icon-preference' for the type order to load.
See `create-image' and `icons--create' and info node `(elisp) Image Descriptors' for the properties of an image."
;; (info "(elisp) Image Descriptors")
;; (emoji "<empji>") see e.g. https://emojipedia.org/hamburger ;; (emoji "<empji>") see e.g. https://emojipedia.org/hamburger
;; (symbol "<unicode>") see e.g. https://www.compart.com/en/unicode/U+2630 ;; (symbol "<unicode>") see e.g. https://www.compart.com/en/unicode/U+2630
(require 'icons) (require 'icons)
@@ -291,12 +340,12 @@ See `icon-preference' for the order of type preference."
(define-icon my-tool-bar-icon-separator nil (define-icon my-tool-bar-icon-separator nil
`((image "separator.xpm" `((image "separator.xpm"
:height (1.5 . em) :height (1.5 . em)
:margin ,tab-bar-button-margin :margin (5 . 1)
:ascent center) :ascent center)
(text " " (text " "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for save." "Separator."
:version "29.1")) :version "29.1"))
(setq my-tool-bar-separator (icon-string 'my-tool-bar-icon-separator)) (setq my-tool-bar-separator (icon-string 'my-tool-bar-icon-separator))
@@ -310,7 +359,7 @@ See `icon-preference' for the order of type preference."
:ascent center) :ascent center)
(emoji "📂") (emoji "📂")
(symbol "🗀 ") ;; 🗁 🗀 (symbol "🗀 ") ;; 🗁 🗀
(text "Open " (text "Opn "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for open file." "Icon for open file."
@@ -327,7 +376,7 @@ See `icon-preference' for the order of type preference."
:ascent center) :ascent center)
(emoji "💾") (emoji "💾")
(symbol "🖫 ") ;; 🖪 🖫 🖬 (symbol "🖫 ") ;; 🖪 🖫 🖬
(text "Save " (text "Sav "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for save." "Icon for save."
@@ -340,7 +389,7 @@ See `icon-preference' for the order of type preference."
:height (1.5 . em) :height (1.5 . em)
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(text "Save as " (text "SvA "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for save as." "Icon for save as."
@@ -357,7 +406,7 @@ See `icon-preference' for the order of type preference."
:ascent center) :ascent center)
(emoji "") (emoji "")
(symbol "🗙 ") ;; 🗙 𐌗 (symbol "🗙 ") ;; 🗙 𐌗
(text "Quit " (text "Qit "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for quit." "Icon for quit."
@@ -371,7 +420,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "") ; ⮔ ♺ (symbol "") ; ⮔ ♺
(text "Prev-buffer " (text "PBf "
)) ))
"Icon for previous buffer." "Icon for previous buffer."
:version "29.1")) :version "29.1"))
@@ -384,7 +433,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "") ; ⮔ ♺ (symbol "") ; ⮔ ♺
(text "Next-buffer " (text "NBf "
)) ))
"Icon for next buffer." "Icon for next buffer."
:version "29.1")) :version "29.1"))
@@ -399,7 +448,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "") ; ⮔ ♺ (symbol "") ; ⮔ ♺
(text "Revert " (text "Rev "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for revert buffer." "Icon for revert buffer."
@@ -415,7 +464,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "") (symbol "")
(text "Undo " (text "UDo "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for undo." "Icon for undo."
@@ -431,7 +480,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "") (symbol "")
(text "Redo " (text "RDo "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for redo." "Icon for redo."
@@ -464,7 +513,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "🗐 ") (symbol "🗐 ")
(text "Copy " (text "Cpy "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for copy region." "Icon for copy region."
@@ -481,7 +530,7 @@ See `icon-preference' for the order of type preference."
:ascent center) :ascent center)
(emoji "📋") (emoji "📋")
(symbol "🗎 ") (symbol "🗎 ")
(text "Paste " (text "Pst "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for paste." "Icon for paste."
@@ -497,7 +546,7 @@ See `icon-preference' for the order of type preference."
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(symbol "") (symbol "")
(text "Fill " (text "Fil "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for fill region." "Icon for fill region."
@@ -510,7 +559,7 @@ See `icon-preference' for the order of type preference."
:height (1.5 . em) :height (1.5 . em)
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(text "Comment " )) (text "Com " ))
"Icon for comment region." "Icon for comment region."
:version "29.1")) :version "29.1"))
(setq my-tool-bar-button-comment (icon-string 'my-tool-bar-icon-comment)) (setq my-tool-bar-button-comment (icon-string 'my-tool-bar-icon-comment))
@@ -521,7 +570,7 @@ See `icon-preference' for the order of type preference."
:height (1.5 . em) :height (1.5 . em)
:margin ,tab-bar-button-margin :margin ,tab-bar-button-margin
:ascent center) :ascent center)
(text "(Un)hide " )) (text "Hid " ))
"Icon for (un)hide elements." "Icon for (un)hide elements."
:version "29.1")) :version "29.1"))
(setq my-tool-bar-button-hide (icon-string 'my-tool-bar-icon-hide)) (setq my-tool-bar-button-hide (icon-string 'my-tool-bar-icon-hide))
@@ -536,7 +585,7 @@ See `icon-preference' for the order of type preference."
:ascent center :ascent center
) )
(symbol "") ;; ⎀ ⎁ ⎂ (symbol "") ;; ⎀ ⎁ ⎂
(text "Spell " (text "Spl "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for spell." "Icon for spell."
@@ -552,13 +601,39 @@ See `icon-preference' for the order of type preference."
:ascent center :ascent center
) )
(symbol " ") (symbol " ")
(text "langtool " (text "Lng "
;; :face tab-bar-tab-inactive ;; :face tab-bar-tab-inactive
)) ))
"Icon for languagetool." "Icon for languagetool."
:version "29.1")) :version "29.1"))
(setq my-tool-bar-button-langtool (icon-string 'my-tool-bar-icon-langtool)) (setq my-tool-bar-button-langtool (icon-string 'my-tool-bar-icon-langtool))
(unless (iconp 'my-tool-bar-icon-play)
(define-icon my-tool-bar-icon-play nil
`((image "Fluent-dark/builder-run-start-symbolic.svg"
:height (1.5 . em)
:margin ,tab-bar-button-margin
:ascent center
)
(text "Run "
))
"Icon for run C-c."
:version "29.1"))
(setq my-tool-bar-button-play (icon-string 'my-tool-bar-icon-play))
(unless (iconp 'my-tool-bar-icon-read)
(define-icon my-tool-bar-icon-read nil
`((image "Fluent-dark/ephy-reader-mode-symbolic.svg"
:height (1.5 . em)
:margin ,tab-bar-button-margin
:ascent center
)
(text "Rdv "
))
"Icon for read view."
:version "29.1"))
(setq my-tool-bar-button-read (icon-string 'my-tool-bar-icon-read))
) )
(define-minor-mode my-tool-bar-mode (define-minor-mode my-tool-bar-mode

View File

@@ -313,14 +313,32 @@ print it in the message buffer."
;; https://emacs.stackexchange.com/questions/7375/can-i-format-cells-in-an-org-mode-table-differently-depending-on-a-formula ;; https://emacs.stackexchange.com/questions/7375/can-i-format-cells-in-an-org-mode-table-differently-depending-on-a-formula
(require 'ov) (require 'ov)
(defun my-org-toggle-emphasis () (setq my-org-latex-preview nil)
(defun my-org-toggle-elements ()
"Toggle hiding/showing of org emphasize markers." "Toggle hiding/showing of org emphasize markers."
(interactive) (interactive)
(if org-hide-emphasis-markers (if org-hide-emphasis-markers
(set-variable 'org-hide-emphasis-markers nil) (set-variable 'org-hide-emphasis-markers nil)
(set-variable 'org-hide-emphasis-markers t)) (set-variable 'org-hide-emphasis-markers t))
(org-mode-restart)) (setq org-link-descriptive (not org-link-descriptive))
(define-key org-mode-map (kbd "C-c C-x C-e") 'my-org-toggle-emphasis) (org-restart-font-lock)
(org-toggle-inline-images)
;; (org-latex-preview)
(if my-org-latex-preview
;; switch off
(let ()
(set-variable 'my-org-latex-preview nil)
(org-latex-preview '(64)))
;; switch on
(set-variable 'my-org-latex-preview t)
(org-latex-preview '(16)))
;; (org-mode-restart)
)
(define-key org-mode-map (kbd "C-c C-x C-e") 'my-org-toggle-elements)
(defun my-org-keywords () (defun my-org-keywords ()
"Parse the buffer and return a cons list of (key . value) "Parse the buffer and return a cons list of (key . value)

View File

@@ -296,7 +296,7 @@ For example in org-mode the link location"
(setq org-hidden-keywords nil) ;; hide keywords like `#+TITLE:` or not, see also `org-appear' (setq org-hidden-keywords nil) ;; hide keywords like `#+TITLE:` or not, see also `org-appear'
(setq org-hide-emphasis-markers nil) ;; hide emphasis marker *_=~/+, see also `org-appear' (setq org-hide-emphasis-markers nil) ;; hide emphasis marker *_=~/+, see also `org-appear'
(setq org-startup-folded nil) ;; nil = showall = #+STARTUP: showall (setq org-startup-folded nil) ;; nil = showall = #+STARTUP: showall
(setq org-startup-with-inline-images t) ;; #+STARTUP: inlineimages|noinlineimages, show inline images when loading a new Org file (setq org-startup-with-inline-images nil) ;; #+STARTUP: inlineimages|noinlineimages, show inline images when loading a new Org file
(setq org-use-sub-superscripts '{}) ;; braces are *required* in order to trigger interpretations as sub/superscript, see also `org-export-with-sub-superscripts'. C-c C-x \ (`org-toggle-pretty-entities') (setq org-use-sub-superscripts '{}) ;; braces are *required* in order to trigger interpretations as sub/superscript, see also `org-export-with-sub-superscripts'. C-c C-x \ (`org-toggle-pretty-entities')
(setq org-pretty-entities nil) ;; so much trouble in an article, see also `org-appear' and [C-c C-x \] (`org-toggle-pretty-entities') (setq org-pretty-entities nil) ;; so much trouble in an article, see also `org-appear' and [C-c C-x \] (`org-toggle-pretty-entities')
(setq org-pretty-entities-include-sub-superscripts t) ;; if `org-pretty-entities' is active include also sub-superscripts. (setq org-pretty-entities-include-sub-superscripts t) ;; if `org-pretty-entities' is active include also sub-superscripts.