unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: eldoc support with M-:
       [not found]           ` <m1ty7sdh11.fsf@gmail.com>
@ 2011-10-02  1:12             ` Stefan Monnier
  2011-10-05  9:20               ` Leo
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2011-10-02  1:12 UTC (permalink / raw)
  To: Leo; +Cc: emacs-devel, Thierry Volpiatto

[ 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* 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

* Re: eldoc support with M-:
  2011-10-05  9:20               ` Leo
@ 2011-10-05 16:29                 ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2011-10-05 16:29 UTC (permalink / raw)
  To: Leo; +Cc: Thierry Volpiatto, emacs-devel

> Sounds good. How about something as shown in the attachment?

Sounds about right.  Please keep it around while we're in feature
freeze.  In the mean time you can try and reimplement eldoc-eval as
a patch against eldoc.el using this approach.


        Stefan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-05 16:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87liy3t6rk.fsf@gmail.com>
     [not found] ` <20110519.175536.23311605.rubikitch@ruby-lang.org>
     [not found]   ` <87hb8rt4ha.fsf@gmail.com>
     [not found]     ` <87liw5z8sl.fsf@gmail.com>
     [not found]       ` <87aabj82sq.fsf@gmail.com>
     [not found]         ` <87vcsazaia.fsf@gmail.com>
     [not found]           ` <m1ty7sdh11.fsf@gmail.com>
2011-10-02  1:12             ` eldoc support with M-: Stefan Monnier
2011-10-05  9:20               ` Leo
2011-10-05 16:29                 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).