[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mouse activated button in modeline
From: |
Heime |
Subject: |
Re: Mouse activated button in modeline |
Date: |
Sun, 21 Jul 2024 19:52:57 +0000 |
On Monday, July 22nd, 2024 at 6:15 AM, Heime <heimeborgia@protonmail.com> wrote:
> I would like to have a button in modeline I can mouse click to toggle the
> file to read-only on-off.
Why does the following not show the mouse activated button
(defface mode-line-read-only-face
'((t :background "red" :foreground "white" :weight bold)))
(defun toggle-read-only-status ()
(interactive)
(if buffer-read-only
(read-only-mode -1)
(read-only-mode 1)))
(defun read-only-button ()
(if buffer-read-only
(propertize " RO "
'face 'mode-line-read-only-face
'help-echo "Read-Only Buffer - Click to toggle."
'mouse-face 'mode-line-highlight
'local-map (make-mode-line-mouse-map
'mouse-1 'toggle-read-only-status))
(propertize " -- "
'help-echo "Writable Buffer - Click to toggle."
'mouse-face 'mode-line-highlight
'local-map (make-mode-line-mouse-map
'mouse-1 'toggle-read-only-status))))
(setq-default mode-line-format
'("%e" '(:eval (read-only-button)) ""))