* Re: eldoc support with M-:
2011-10-02 1:12 ` eldoc support with M-: Stefan Monnier
@ 2011-10-05 9:20 ` Leo
2011-10-05 16:29 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Leo @ 2011-10-05 9:20 UTC (permalink / raw
To: Stefan Monnier; +Cc: Thierry Volpiatto, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 648 bytes --]
On 2011-10-02 09:12 +0800, Stefan Monnier wrote:
> [ Moved away from gnu.emacs.sources where it doesn't belong any more. ]
>
>>> you will find now last version of eldoc-eval.el in GNU ELPA.
>> I wonder if it makes sense to provide a message-function to customise
>> how `message' posts its messages.
>
> I think doing it for `message' is a bit too radical. But an
> eldoc-message-function hook would be perfectly fine, and I still hope
> (despite Thierry's failure to figure out how) that such a hook can be
> used to simplify (and integrate) eldoc-eval.el.
>
>
> Stefan
Sounds good. How about something as shown in the attachment?
Leo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: eldoc-modeline --]
[-- Type: text/x-diff, Size: 2363 bytes --]
=== modified file 'lisp/emacs-lisp/eldoc.el'
--- lisp/emacs-lisp/eldoc.el 2011-01-25 04:08:28 +0000
+++ lisp/emacs-lisp/eldoc.el 2011-10-05 09:15:52 +0000
@@ -146,6 +146,11 @@
"Idle time delay currently in use by timer.
This is used to determine if `eldoc-idle-delay' is changed by the user.")
+(defvar eldoc-message-function nil
+ "The function used by `eldoc-message' to display messages.
+It should receive the same arguments as `message'. If this is
+nil, `eldoc-minibuffer-message' is used.")
+
\f
;;;###autoload
(define-minor-mode eldoc-mode
@@ -185,8 +190,30 @@
(setq eldoc-current-idle-delay eldoc-idle-delay)
(timer-set-idle-time eldoc-timer eldoc-idle-delay t))))
+(defvar eldoc-mode-line-string nil)
+(put 'eldoc-mode-line-string 'risky-local-variable t)
+
+(defun eldoc-minibuffer-message (format-string &rest args)
+ "Show messages in the mode-line when in the minibuffer.
+Otherwise, behave like function `message'."
+ (if (minibufferp)
+ (progn
+ (with-current-buffer (window-buffer (minibuffer-selected-window))
+ (unless (assq 'eldoc-mode-line-string mode-line-format)
+ (push '(eldoc-mode-line-string (" " eldoc-mode-line-string " "))
+ mode-line-format)))
+ (add-hook 'minibuffer-exit-hook
+ (lambda () (setq eldoc-mode-line-string nil))
+ nil t)
+ (and (stringp format-string)
+ (setq eldoc-mode-line-string
+ (apply 'format format-string args)))
+ (force-mode-line-update))
+ (apply 'message format-string args)))
+
(defun eldoc-message (&rest args)
- (let ((omessage eldoc-last-message))
+ (let ((omessage eldoc-last-message)
+ (msgfunc (or eldoc-message-function #'eldoc-minibuffer-message)))
(setq eldoc-last-message
(cond ((eq (car args) eldoc-last-message) eldoc-last-message)
((null (car args)) nil)
@@ -200,8 +227,8 @@
;; they are Legion.
;; Emacs way of preventing log messages.
(let ((message-log-max nil))
- (cond (eldoc-last-message (message "%s" eldoc-last-message))
- (omessage (message nil)))))
+ (cond (eldoc-last-message (funcall msgfunc "%s" eldoc-last-message))
+ (omessage (funcall msgfunc nil)))))
eldoc-last-message)
;; This function goes on pre-command-hook for XEmacs or when using idle
^ permalink raw reply [flat|nested] 3+ messages in thread