Add modified outside of emacs icon

This commit is contained in:
Matthew L. Fidler 2016-02-26 09:29:43 -06:00
parent 89bfa214dc
commit 78a6347835

View file

@ -301,25 +301,38 @@ the icon."
'local-map 'local-map
'(keymap '(keymap
(mode-line keymap (mode-line keymap
(mouse-1 . mode-icons-save-buffer) (mouse-1 . mode-icons-save-or-revert-buffer)
(mouse-3 . mode-line-toggle-modified))) (mouse-3 . mode-line-toggle-modified)))
'help-echo 'mode-icons-modified-help-echo) 'help-echo 'mode-icons-modified-help-echo)
"List of text propeties to apply to read-only buffer indicator." "List of text propeties to apply to read-only buffer indicator."
:type '(repeat sexp) :type '(repeat sexp)
:group 'mode-icons) :group 'mode-icons)
(defun mode-icons-save-buffer (event) (defun mode-icons-save-or-revert-buffer (event)
"Save buffer from mode line. "Save buffer OR revert file from mode line.
Use EVENT to determine location." Use EVENT to determine location."
(interactive "e") (interactive "e")
(with-selected-window (posn-window (event-start event)) (with-selected-window (posn-window (event-start event))
(call-interactively (key-binding (where-is-internal 'save-buffer global-map t))) (if (not (or (and (buffer-file-name) (file-remote-p buffer-file-name))
(verify-visited-file-modtime (current-buffer))))
(revert-buffer t t)
(call-interactively (key-binding (where-is-internal 'save-buffer global-map t))))
(force-mode-line-update))) (force-mode-line-update)))
(defun mode-icons-modified-help-echo (window _object _point) (defun mode-icons-modified-help-echo (window _object _point)
"Return help text specifying WINDOW's buffer modification status." "Return help text specifying WINDOW's buffer modification status."
(format "Buffer is %smodified\nmouse-1: Save Buffer\nmouse-3: Toggle modification state" (format "Buffer is %s\nmouse-1: %s Buffer\nmouse-3: Toggle modification state"
(if (buffer-modified-p (window-buffer window)) "" "not "))) (cond
((not (or (and (buffer-file-name) (file-remote-p buffer-file-name))
(verify-visited-file-modtime (current-buffer))))
"modified outside of emacs!")
((buffer-modified-p (window-buffer window))
"modified")
(t "unmodified"))
(if (not (or (and (buffer-file-name) (file-remote-p buffer-file-name))
(verify-visited-file-modtime (current-buffer))))
"Revert"
"Save")))
(defcustom mode-icons-read-only-text-properties (defcustom mode-icons-read-only-text-properties
'('mouse-face 'mode-line-highlight 'local-map '('mouse-face 'mode-line-highlight 'local-map