summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2020-11-01 20:58:08 +0000
committerjao <jao@gnu.org>2020-11-01 20:58:08 +0000
commitd372785c2b31581b581b7d809a0e66ae2a99a1fa (patch)
tree535ec78a4e7bae1023d1878b2fd2603a2669ffcf
parentb60b6442cc40a00f3476668655e166f0cfc58e36 (diff)
downloadelibs-d372785c2b31581b581b7d809a0e66ae2a99a1fa.tar.gz
elibs-d372785c2b31581b581b7d809a0e66ae2a99a1fa.tar.bz2
jao-minibuffer: set/clear-message-function in lieu of advice
-rw-r--r--misc/jao-minibuffer.el30
1 files changed, 16 insertions, 14 deletions
diff --git a/misc/jao-minibuffer.el b/misc/jao-minibuffer.el
index 6af3730..746a925 100644
--- a/misc/jao-minibuffer.el
+++ b/misc/jao-minibuffer.el
@@ -37,29 +37,28 @@
(format (format "%%%ds" w) s)
(substring s 0 w)))
-(defun jao-minibuffer--aligned (&optional w)
- (let ((msg (string-trim (format-mode-line (or jao-minibuffer-notification
- jao-minibuffer-info)))))
+(defun jao-minibuffer--current ()
+ (with-current-buffer jao-minibuffer--name
+ (buffer-substring (point-min) (point-max))))
+
+(defun jao-minibuffer--aligned (&optional w currentp)
+ (let ((msg (string-trim (if currentp
+ (jao-minibuffer--current)
+ (format-mode-line (or jao-minibuffer-notification
+ jao-minibuffer-info))))))
(when (not (string-empty-p msg))
(if jao-minibuffer-align-right-p
(let* ((mw (if jao-minibuffer-maximized-frames-p
(frame-width)
(window-width (minibuffer-window))))
- (w (mod (or w 0) mw))
+ (w (mod (or w (length (current-message))) mw))
(w (- mw w jao-minibuffer-right-margin)))
(if (> w 0) (jao-minibuffer--trim msg w) ""))
(concat " ยท " msg)))))
-(defun jao-minibuffer--message (old-func &rest args)
- (let* ((msg (let ((inhibit-message t)) (apply old-func args)))
- (msg (if inhibit-message "" msg))
- (new-msg (concat msg (jao-minibuffer--aligned (length msg))))
- (message-log-max nil)
- (inhibit-message nil))
- (funcall old-func "%s" new-msg)
- msg))
-
-(advice-add #'message :around #'jao-minibuffer--message)
+(defun jao-minibuffer--set-message (msg)
+ (let ((msg (replace-regexp-in-string "\n" " " msg)))
+ (concat msg (jao-minibuffer--aligned (length msg) t))))
;;;###autoload
(defun jao-minibuffer-refresh ()
@@ -83,5 +82,8 @@
(setq jao-minibuffer-notification nil)
(jao-minibuffer-refresh))
+(setq set-message-function #'jao-minibuffer--set-message)
+(setq clear-message-function #'jao-minibuffer-refresh)
+
(provide 'jao-minibuffer)
;;; jao-minibuffer.el ends here