unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ElDoc: adding optional support to display messages in header-line  instead of the echo area
@ 2009-08-01  9:46 Geralt
  2009-08-02  9:33 ` martin rudalics
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Geralt @ 2009-08-01  9:46 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]

Hi,

I've added to ElDoc a customizable flag to redirect the output into
the header-line instead of the echo area. It's my first contribution
and I'm not sure if the patch is implementing the functionality good
enough to make it into Emacs. I'd like to hear your feedback :)

Here's the patch (and as attachement too, because GoogleMail is doing
changes to whitespace):
--- eldoc.el	2009-07-31 18:03:58.000000000 +0200
+++ eldoc.el	2009-08-01 11:43:29.587798820 +0200
@@ -105,6 +105,12 @@
  enable argument list to fit on one line" truncate-sym-name-if-fit))
   :group 'eldoc)

+(defcustom eldoc-display-in-header-line nil
+  "If set eldoc will display its messages in the topmost line of the
window, called the header-line, instead of the echo area.
+Use only when eldoc-echo-area-use-multiline-p is set to nil."
+  :type 'boolean
+  :group 'eldoc)
+
 (defface eldoc-highlight-function-argument
   '((t (:inherit bold)))
   "Face used for the argument at point in a function's argument list.
@@ -201,8 +207,10 @@
     ;; 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 (if eldoc-display-in-header-line
+				    (setq header-line-format eldoc-last-message)
+				  (message "%s" eldoc-last-message)
+				  (omessage (message nil)))))))
   eldoc-last-message)

 ;; This function goes on pre-command-hook for XEmacs or when using idle




Geralt.

[-- Attachment #2: eldoc-display-in-header-line.patch --]
[-- Type: application/octet-stream, Size: 1148 bytes --]

--- eldoc.el	2009-07-31 18:03:58.000000000 +0200
+++ eldoc.el	2009-08-01 11:43:29.587798820 +0200
@@ -105,6 +105,12 @@
  enable argument list to fit on one line" truncate-sym-name-if-fit))
   :group 'eldoc)
 
+(defcustom eldoc-display-in-header-line nil
+  "If set eldoc will display its messages in the topmost line of the window, called the header-line, instead of the echo area.
+Use only when eldoc-echo-area-use-multiline-p is set to nil."
+  :type 'boolean
+  :group 'eldoc)
+
 (defface eldoc-highlight-function-argument
   '((t (:inherit bold)))
   "Face used for the argument at point in a function's argument list.
@@ -201,8 +207,10 @@
     ;; 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 (if eldoc-display-in-header-line
+				    (setq header-line-format eldoc-last-message)
+				  (message "%s" eldoc-last-message)
+				  (omessage (message nil)))))))
   eldoc-last-message)
 
 ;; This function goes on pre-command-hook for XEmacs or when using idle

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

* Re: ElDoc: adding optional support to display messages in header-line instead of the echo area
  2009-08-01  9:46 ElDoc: adding optional support to display messages in header-line instead of the echo area Geralt
@ 2009-08-02  9:33 ` martin rudalics
  2009-08-03 21:47   ` Geralt
  2009-08-04 17:05 ` ElDoc: adding optional support to display messages in header-line Stefan Monnier
  2009-08-04 17:07 ` Stefan Monnier
  2 siblings, 1 reply; 12+ messages in thread
From: martin rudalics @ 2009-08-02  9:33 UTC (permalink / raw)
  To: Geralt; +Cc: emacs-devel

 > +      (cond (eldoc-last-message (if eldoc-display-in-header-line
 > +				    (setq header-line-format eldoc-last-message)
 > +				  (message "%s" eldoc-last-message)
 > +				  (omessage (message nil)))))))

You probably mean something like

       (cond
        (eldoc-last-message
	(if eldoc-display-in-header-line
	    (setq header-line-format eldoc-last-message)
	  (message "%s" eldoc-last-message)))
        (omessage (message nil)))))

here ;-)

martin




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

* Re: ElDoc: adding optional support to display messages in header-line instead of the echo area
  2009-08-02  9:33 ` martin rudalics
@ 2009-08-03 21:47   ` Geralt
  2009-08-04  7:10     ` Tassilo Horn
  2009-08-04  8:32     ` martin rudalics
  0 siblings, 2 replies; 12+ messages in thread
From: Geralt @ 2009-08-03 21:47 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

On Sun, Aug 2, 2009 at 11:33 AM, martin rudalics<rudalics@gmx.at> wrote:
>> +      (cond (eldoc-last-message (if eldoc-display-in-header-line
>> +                                 (setq header-line-format
>> eldoc-last-message)
>> +                               (message "%s" eldoc-last-message)
>> +                               (omessage (message nil)))))))
>
> You probably mean something like
>
>      (cond
>       (eldoc-last-message
>        (if eldoc-display-in-header-line
>            (setq header-line-format eldoc-last-message)
>          (message "%s" eldoc-last-message)))
>       (omessage (message nil)))))
>
> here ;-)
>
> martin
>
Hi Martin,

can you explain why? I put the omessage into the ELSE block because
somebody on emacs-help suggested it and it made sense to me at that
time.



Geralt.




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

* Re: ElDoc: adding optional support to display messages in header-line instead of the echo area
  2009-08-03 21:47   ` Geralt
@ 2009-08-04  7:10     ` Tassilo Horn
  2009-08-04  8:32     ` martin rudalics
  1 sibling, 0 replies; 12+ messages in thread
From: Tassilo Horn @ 2009-08-04  7:10 UTC (permalink / raw)
  To: Geralt; +Cc: martin rudalics, emacs-devel

Geralt <usr.gentoo@googlemail.com> writes:

Hi!

>> You probably mean something like
>>
>>      (cond
>>       (eldoc-last-message
>>        (if eldoc-display-in-header-line
>>            (setq header-line-format eldoc-last-message)
>>          (message "%s" eldoc-last-message)))
>>       (omessage (message nil)))))
>>
>> here ;-)
>
> can you explain why?

Cause the variable `omessage' is bound to `eldoc-last-message' in the
beginning of the function, and it serves as condition in the `cond'.
After the `let', `eldoc-last-message' set to the new eldoc string.  If
there's non created, cause point is not on a function/var, then the new
value is nil.  If that is the case, but the old message (omessage) is
non-nil, the echo area will be cleared.

> I put the omessage into the ELSE block because somebody on emacs-help
> suggested it and it made sense to me at that time.

Yep, been there, didn't check accurately, didn't object.  But Martin is
right. :-)

Bye,
Tassilo




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

* Re: ElDoc: adding optional support to display messages in header-line instead of the echo area
  2009-08-03 21:47   ` Geralt
  2009-08-04  7:10     ` Tassilo Horn
@ 2009-08-04  8:32     ` martin rudalics
  2009-08-04 18:50       ` Geralt
  1 sibling, 1 reply; 12+ messages in thread
From: martin rudalics @ 2009-08-04  8:32 UTC (permalink / raw)
  To: Geralt; +Cc: emacs-devel

 > can you explain why? I put the omessage into the ELSE block because
 > somebody on emacs-help suggested it and it made sense to me at that
 > time.

Compiling eldoc.el after applying your patch gets me

eldoc-new.el~:550:1:Warning: the function `omessage' is not known to be
     defined.

This happens because in the

       (cond (eldoc-last-message (if eldoc-display-in-header-line
				    (setq header-line-format eldoc-last-message)
				  (message "%s" eldoc-last-message)
				  (omessage (message nil)))))))

form you misplaced the parentheses and thus `omessage' is not considered
a condition of some clause of the `cond' special form but as a function
call.

BTW, I suppose you also need to call `force-mode-line-update' because
Emacs does not necessarily update the contents of the header line when
just moving point.

martin




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

* Re: ElDoc: adding optional support to display messages in header-line
  2009-08-01  9:46 ElDoc: adding optional support to display messages in header-line instead of the echo area Geralt
  2009-08-02  9:33 ` martin rudalics
@ 2009-08-04 17:05 ` Stefan Monnier
  2009-08-04 19:05   ` Geralt
  2009-08-04 17:07 ` Stefan Monnier
  2 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2009-08-04 17:05 UTC (permalink / raw)
  To: Geralt; +Cc: emacs-devel

> +		    (setq header-line-format eldoc-last-message)

If eldoc-last-message contains % characters, this can lead to surprising
results, because they get special treatment.  Better set
header-line-format to '("" eldoc-message) in eldoc-mode and then set
eldoc-message here.


        Stefan





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

* Re: ElDoc: adding optional support to display messages in header-line
  2009-08-01  9:46 ElDoc: adding optional support to display messages in header-line instead of the echo area Geralt
  2009-08-02  9:33 ` martin rudalics
  2009-08-04 17:05 ` ElDoc: adding optional support to display messages in header-line Stefan Monnier
@ 2009-08-04 17:07 ` Stefan Monnier
  2009-08-04 19:06   ` Geralt
  2 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2009-08-04 17:07 UTC (permalink / raw)
  To: Geralt; +Cc: emacs-devel

> I've added to ElDoc a customizable flag to redirect the output into
> the header-line instead of the echo area. It's my first contribution
> and I'm not sure if the patch is implementing the functionality good
> enough to make it into Emacs. I'd like to hear your feedback :)

BTW, I'm not sure it's a good feature.  Also, the docstring of
eldoc-display-in-header-line needs to start with a line that stands on
its own.


        Stefan




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

* Re: ElDoc: adding optional support to display messages in header-line instead of the echo area
  2009-08-04  8:32     ` martin rudalics
@ 2009-08-04 18:50       ` Geralt
  0 siblings, 0 replies; 12+ messages in thread
From: Geralt @ 2009-08-04 18:50 UTC (permalink / raw)
  To: martin rudalics; +Cc: Tassilo Horn, emacs-devel

On Tue, Aug 4, 2009 at 10:32 AM, martin rudalics<rudalics@gmx.at> wrote:
>> can you explain why? I put the omessage into the ELSE block because
>> somebody on emacs-help suggested it and it made sense to me at that
>> time.
>
> Compiling eldoc.el after applying your patch gets me
>
> eldoc-new.el~:550:1:Warning: the function `omessage' is not known to be
>    defined.
>
> This happens because in the
>
>      (cond (eldoc-last-message (if eldoc-display-in-header-line
>                                    (setq header-line-format
> eldoc-last-message)
>                                  (message "%s" eldoc-last-message)
>                                  (omessage (message nil)))))))
>
> form you misplaced the parentheses and thus `omessage' is not considered
> a condition of some clause of the `cond' special form but as a function
> call.
>
> BTW, I suppose you also need to call `force-mode-line-update' because
> Emacs does not necessarily update the contents of the header line when
> just moving point.
>
> martin
>

Ok, I did all the changes, here's the patch with all the changes:

--- eldoc.el	2009-08-04 20:48:20.789335848 +0200
+++ eldoc.el	2009-08-04 20:47:34.350337476 +0200
@@ -105,6 +105,11 @@
  enable argument list to fit on one line" truncate-sym-name-if-fit))
   :group 'eldoc)

+(defcustom eldoc-display-in-header-line nil
+  "If set eldoc will display its messages in the topmost line of the
window, called the header-line, instead of the echo area."
+  :type 'boolean
+  :group 'eldoc)
+
 (defface eldoc-highlight-function-argument
   '((t (:inherit bold)))
   "Face used for the argument at point in a function's argument list.
@@ -201,7 +206,11 @@
     ;; they are Legion.
     ;; Emacs way of preventing log messages.
     (let ((message-log-max nil))
-      (cond (eldoc-last-message (message "%s" eldoc-last-message))
+      (cond (eldoc-last-message (if eldoc-display-in-header-line
+				    (progn
+				      (setq header-line-format eldoc-last-message)
+				      (force-mode-line-update))
+				  (message "%s" eldoc-last-message)))
 	    (omessage (message nil)))))
   eldoc-last-message)



Geralt.




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

* Re: ElDoc: adding optional support to display messages in header-line
  2009-08-04 17:05 ` ElDoc: adding optional support to display messages in header-line Stefan Monnier
@ 2009-08-04 19:05   ` Geralt
  2009-08-05  2:00     ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Geralt @ 2009-08-04 19:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Tue, Aug 4, 2009 at 7:05 PM, Stefan Monnier<monnier@iro.umontreal.ca> wrote:
>> +                 (setq header-line-format eldoc-last-message)
>
> If eldoc-last-message contains % characters, this can lead to surprising
> results, because they get special treatment.  Better set
> header-line-format to '("" eldoc-message) in eldoc-mode and then set
> eldoc-message here.
>
>
>        Stefan
>
>
I tried that, but then the output in the header line is no longer
using the syntax colors of the current mode. Is there a way to get
both?



Geralt.




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

* Re: ElDoc: adding optional support to display messages in header-line
  2009-08-04 17:07 ` Stefan Monnier
@ 2009-08-04 19:06   ` Geralt
  0 siblings, 0 replies; 12+ messages in thread
From: Geralt @ 2009-08-04 19:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Tue, Aug 4, 2009 at 7:07 PM, Stefan Monnier<monnier@iro.umontreal.ca> wrote:
>> I've added to ElDoc a customizable flag to redirect the output into
>> the header-line instead of the echo area. It's my first contribution
>> and I'm not sure if the patch is implementing the functionality good
>> enough to make it into Emacs. I'd like to hear your feedback :)
>
> BTW, I'm not sure it's a good feature.  Also, the docstring of
> eldoc-display-in-header-line needs to start with a line that stands on
> its own.
>
>
>        Stefan
>
Ok, thanks, I'll change the docstring.



Geralt.




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

* Re: ElDoc: adding optional support to display messages in header-line
  2009-08-04 19:05   ` Geralt
@ 2009-08-05  2:00     ` Stefan Monnier
  2009-08-06 18:50       ` Geralt
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2009-08-05  2:00 UTC (permalink / raw)
  To: Geralt; +Cc: emacs-devel

> I tried that, but then the output in the header line is no longer
> using the syntax colors of the current mode. Is there a way to get
> both?

Yesm you need to (put 'eldoc-messagee 'risky-local-variable t)


        Stefa




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

* Re: ElDoc: adding optional support to display messages in header-line
  2009-08-05  2:00     ` Stefan Monnier
@ 2009-08-06 18:50       ` Geralt
  0 siblings, 0 replies; 12+ messages in thread
From: Geralt @ 2009-08-06 18:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Wed, Aug 5, 2009 at 4:00 AM, Stefan Monnier<monnier@iro.umontreal.ca> wrote:
>> I tried that, but then the output in the header line is no longer
>> using the syntax colors of the current mode. Is there a way to get
>> both?
>
> Yesm you need to (put 'eldoc-messagee 'risky-local-variable t)
>
>
>        Stefa
>
Thanks. Where can I get information about properties (like this one)?
I couldn't find anything with C-a or searching through the emacs info
page(s).




Geralt.




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

end of thread, other threads:[~2009-08-06 18:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-01  9:46 ElDoc: adding optional support to display messages in header-line instead of the echo area Geralt
2009-08-02  9:33 ` martin rudalics
2009-08-03 21:47   ` Geralt
2009-08-04  7:10     ` Tassilo Horn
2009-08-04  8:32     ` martin rudalics
2009-08-04 18:50       ` Geralt
2009-08-04 17:05 ` ElDoc: adding optional support to display messages in header-line Stefan Monnier
2009-08-04 19:05   ` Geralt
2009-08-05  2:00     ` Stefan Monnier
2009-08-06 18:50       ` Geralt
2009-08-04 17:07 ` Stefan Monnier
2009-08-04 19:06   ` Geralt

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).