From 1eee0de460eb78be05538a03c7d1d904f211cab0 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 20 Jan 2015 14:37:01 +0100 Subject: Properly show function arguments in the modeline When one is working in the minibuffer, using eval, the function arguments are shown in the modeline. This normally messes up the modeline when using an SVG modeline, but with this function it should show it properly. --- emacs/.emacs.d/site-lisp/my-smt.el | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/site-lisp/my-smt.el b/emacs/.emacs.d/site-lisp/my-smt.el index afc2d59..5d81091 100644 --- a/emacs/.emacs.d/site-lisp/my-smt.el +++ b/emacs/.emacs.d/site-lisp/my-smt.el @@ -45,6 +45,36 @@ (not (equal jabber-activity-mode-string ""))) (concat jabber-activity-mode-string " ")))) +;;; TODO Turn: +;; #("message: (FORMAT-STRING &rest ARGS)" +;; 0 7 (face font-lock-function-name-face) +;; 10 23 (face eldoc-highlight-function-argument)) +;;; into: +;;; (tspan (tspan :fill (fg-color font-lock-function-name-face) "message:") +;;; " (" +;;; (tspan :fill (fg-color highlight-function-argument) "FORMAT-STRING") +;;; " &rest ARGS)") +(defun my-smt-eldoc-minibuffer-message (format-string &rest args) + (if (minibufferp) + (progn + (add-hook 'minibuffer-exit-hook + (lambda () (setq my-smt-eldoc-message nil + eldoc-mode-line-string nil + eldoc-last-message nil)) + nil t) + (setq my-smt-eldoc-message + (when (stringp format-string) + (apply 'format format-string args))) + (force-mode-line-update t)) + (apply 'message format-string args))) + +(defvar my-smt-eldoc-message nil) +(smt/defwidget my-smt-eldoc-message + :text (lambda (widget) + (ignore widget) + (when my-smt-eldoc-message + `(tspan :fill "#bfbfbf" " (" (tspan :fill "#5476a8" ,my-smt-eldoc-message) ")")))) + (defun my-smt-yoshi-title-style (widget) "Fill color for either active or inactive windows. @@ -112,7 +142,7 @@ WIDGET is ignored." (smt/defrow my-smt-left :prototype 'default-left :widgets '(buffer-info my-smt-buffer-identification my-smt-po-counters - which-function)) + which-function my-smt-eldoc-message)) (smt/defrow my-smt-position :prototype 'default-position @@ -131,5 +161,8 @@ WIDGET is ignored." :style 'my-smt-major-mode-style))) :rows '(my-smt-left my-smt-position my-smt-right)) +(add-function :override (symbol-function 'eldoc-minibuffer-message) + #'my-smt-eldoc-minibuffer-message) + (provide 'my-smt) ;;; my-smt.el ends here -- cgit v1.2.3-54-g00ecf