aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew L. Fidler2016-02-26 09:29:43 -0600
committerMatthew L. Fidler2016-02-26 09:29:43 -0600
commit78a63478350677958f9f0757703fd775834ea496 (patch)
tree4bf2dd42051b948d3572c1186263fbd3012be3ad
parent89bfa214dcc64ae13e4d459d2089d97465955c03 (diff)
downloadmode-icons-78a63478350677958f9f0757703fd775834ea496.tar.gz
mode-icons-78a63478350677958f9f0757703fd775834ea496.zip
Add modified outside of emacs icon
-rw-r--r--mode-icons.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/mode-icons.el b/mode-icons.el
index abc29c2..9241e99 100644
--- a/mode-icons.el
+++ b/mode-icons.el
@@ -301,25 +301,38 @@ the icon."
'local-map
'(keymap
(mode-line keymap
- (mouse-1 . mode-icons-save-buffer)
+ (mouse-1 . mode-icons-save-or-revert-buffer)
(mouse-3 . mode-line-toggle-modified)))
'help-echo 'mode-icons-modified-help-echo)
"List of text propeties to apply to read-only buffer indicator."
:type '(repeat sexp)
:group 'mode-icons)
-(defun mode-icons-save-buffer (event)
- "Save buffer from mode line.
+(defun mode-icons-save-or-revert-buffer (event)
+ "Save buffer OR revert file from mode line.
Use EVENT to determine location."
(interactive "e")
(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)))
(defun mode-icons-modified-help-echo (window _object _point)
"Return help text specifying WINDOW's buffer modification status."
- (format "Buffer is %smodified\nmouse-1: Save Buffer\nmouse-3: Toggle modification state"
- (if (buffer-modified-p (window-buffer window)) "" "not ")))
+ (format "Buffer is %s\nmouse-1: %s Buffer\nmouse-3: Toggle modification state"
+ (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
'('mouse-face 'mode-line-highlight 'local-map