* Re: header-line-format hacking
[not found] <mailman.15144.1106647267.27204.help-gnu-emacs@gnu.org>
@ 2005-01-25 10:50 ` David Hansen
2005-01-25 13:05 ` ytrewq1
[not found] ` <mailman.15179.1106660077.27204.help-gnu-emacs@gnu.org>
2005-01-31 16:18 ` Stefan Monnier
1 sibling, 2 replies; 15+ messages in thread
From: David Hansen @ 2005-01-25 10:50 UTC (permalink / raw)
On Tue, 25 Jan 2005 09:30:42 +0000 (UTC) ytrewq1 <ytrewq1@gmail.com> wrote:
> Is there a recommended way to modify header-line-format? If
> possible, I'd like to augment an existing value (for cases
> where that makes sense) rather than override it. Grepping
> Emacs source, I've noticed a few places where it's overridden
> but haven't found an example of modification.
Just set `header-line-format', e.g:
(setq header-line-format (concat (or header-line-format "") " test"))
will append " test" to the header line of the current buffer.
David
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
2005-01-25 10:50 ` header-line-format hacking David Hansen
@ 2005-01-25 13:05 ` ytrewq1
[not found] ` <mailman.15179.1106660077.27204.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-25 13:05 UTC (permalink / raw)
David Hansen writes:
> Just set `header-line-format', e.g:
>
> (setq header-line-format (concat (or header-line-format "") " test"))
>
> will append " test" to the header line of the current buffer.
I was under the impression that the header-line-format variable
can hold a template like the one that mode-line-format uses. If
that's the case, wouldn't the code snippet above not work for
non-string templates?
^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <mailman.15179.1106660077.27204.help-gnu-emacs@gnu.org>]
* Re: header-line-format hacking
[not found] ` <mailman.15179.1106660077.27204.help-gnu-emacs@gnu.org>
@ 2005-01-25 18:49 ` Kevin Rodgers
2005-01-26 2:25 ` ytrewq1
[not found] ` <mailman.15337.1106708876.27204.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 15+ messages in thread
From: Kevin Rodgers @ 2005-01-25 18:49 UTC (permalink / raw)
ytrewq1 wrote:
> David Hansen writes:
>>Just set `header-line-format', e.g:
>>
>>(setq header-line-format (concat (or header-line-format "") " test"))
>>
>>will append " test" to the header line of the current buffer.
>
> I was under the impression that the header-line-format variable
> can hold a template like the one that mode-line-format uses. If
> that's the case, wouldn't the code snippet above not work for
> non-string templates?
Exactly.
(setq header-line-format
(cond ((null header-line-format) my-header-line-format)
((stringp header-line-format)
(list header-line-format my-header-line-format))
((symbolp header-line-format)
(list (list t header-line-format) my-header-line-format))
((consp header-line-format)
(append header-line-format (list my-header-line-format)))))
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
2005-01-25 18:49 ` Kevin Rodgers
@ 2005-01-26 2:25 ` ytrewq1
[not found] ` <mailman.15337.1106708876.27204.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-26 2:25 UTC (permalink / raw)
Kevin Rodgers writes:
> (setq header-line-format
> (cond ((null header-line-format) my-header-line-format)
> ((stringp header-line-format)
> (list header-line-format my-header-line-format))
> ((symbolp header-line-format)
> (list (list t header-line-format) my-header-line-format))
> ((consp header-line-format)
> (append header-line-format (list my-header-line-format)))))
Thanks.
I'm thinking of putting something like the above in the set-up portion
of a couple of minor modes I'm working on. It occurs to me though
if I were to turn the minor mode on, off, and then on again, I'll
be repeatedly adding my format to header-line-format. I suppose one
way to prevent this would be to have the minor mode code try to
detect if the header-line-format has already been modified by the
minor mode. Does that sound like a reasonable/practical approach?
^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <mailman.15337.1106708876.27204.help-gnu-emacs@gnu.org>]
* Re: header-line-format hacking
[not found] ` <mailman.15337.1106708876.27204.help-gnu-emacs@gnu.org>
@ 2005-01-26 11:04 ` Thien-Thi Nguyen
2005-01-26 13:09 ` ytrewq1
[not found] ` <mailman.15408.1106746330.27204.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 15+ messages in thread
From: Thien-Thi Nguyen @ 2005-01-26 11:04 UTC (permalink / raw)
ytrewq1 <ytrewq1@gmail.com> writes:
> Does that sound like a reasonable/practical approach?
it is reasonable and practical but not idiomatic.
more idiomatic is to have the minor mode define a variable
that has value nil when the minor mode is inactive. then,
you add the variable to the formatting tree unconditionally,
and the display engine takes care of things automatically.
thi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
2005-01-26 11:04 ` Thien-Thi Nguyen
@ 2005-01-26 13:09 ` ytrewq1
[not found] ` <mailman.15408.1106746330.27204.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-26 13:09 UTC (permalink / raw)
Thien-Thi Nguyen writes:
> more idiomatic is to have the minor mode define a variable
> that has value nil when the minor mode is inactive. then,
> you add the variable to the formatting tree unconditionally,
> and the display engine takes care of things automatically.
I don't think I quite follow you. Do you mean that the minor
mode code should not be modifying header-line-format? If it's
not supposed to, does that mean each user should add something
to their .emacs to define header-line-format?
^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <mailman.15408.1106746330.27204.help-gnu-emacs@gnu.org>]
* Re: header-line-format hacking
[not found] ` <mailman.15408.1106746330.27204.help-gnu-emacs@gnu.org>
@ 2005-01-26 14:12 ` Thien-Thi Nguyen
2005-01-31 2:36 ` (apparently lost, so rewritten and reposted) " ytrewq1
[not found] ` <mailman.70.1107140500.2841.help-gnu-emacs@gnu.org>
2005-01-26 23:37 ` Kevin Rodgers
1 sibling, 2 replies; 15+ messages in thread
From: Thien-Thi Nguyen @ 2005-01-26 14:12 UTC (permalink / raw)
ytrewq1 <ytrewq1@gmail.com> writes:
> I don't think I quite follow you. Do you mean that the minor
> mode code should not be modifying header-line-format? If it's
> not supposed to, does that mean each user should add something
> to their .emacs to define header-line-format?
the minor mode code presuambly comprises a bunch of defuns
plus some "load-time actions". the load-time actions is
where the variable is inserted into `header-line-format'
(be sure to check that it's not already there).
the idea is to modify `header-line-format' at most one time,
and use indirection (through the variable) to effect state
toggling and notification.
thi
^ permalink raw reply [flat|nested] 15+ messages in thread
* (apparently lost, so rewritten and reposted) Re: header-line-format hacking
2005-01-26 14:12 ` Thien-Thi Nguyen
@ 2005-01-31 2:36 ` ytrewq1
[not found] ` <mailman.70.1107140500.2841.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-31 2:36 UTC (permalink / raw)
Thien-Thi Nguyen writes:
> the minor mode code presuambly comprises a bunch of defuns
> plus some "load-time actions". the load-time actions is
> where the variable is inserted into `header-line-format'
> (be sure to check that it's not already there).
>
> the idea is to modify `header-line-format' at most one time,
> and use indirection (through the variable) to effect state
> toggling and notification.
Thanks for the explanation.
I think I understand how this approach could work for
mode-line-format as it's default value is non-nil. However,
on my system, header-line-format has a default value of
nil. As far as I can tell, if a buffer's header-line-format
value is modified to be non-nil a header is displayed -- so
if a buffer starts out w/ a header-line-format value of nil
and minor mode code modifies it to be non-nil, deactivation
of the minor mode will cause the buffer to have an empty
header line ("baggage").
Is there a way to avoid this "baggage" using the idiomatic
approach?
^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <mailman.70.1107140500.2841.help-gnu-emacs@gnu.org>]
* Re: (apparently lost, so rewritten and reposted) Re: header-line-format hacking
[not found] ` <mailman.70.1107140500.2841.help-gnu-emacs@gnu.org>
@ 2005-01-31 9:54 ` Thien-Thi Nguyen
0 siblings, 0 replies; 15+ messages in thread
From: Thien-Thi Nguyen @ 2005-01-31 9:54 UTC (permalink / raw)
ytrewq1 <ytrewq1@gmail.com> writes:
> Thanks for the explanation.
well, looks like the explanation did not cover this case...
> I think I understand how this approach could work for
> mode-line-format as it's default value is non-nil. However,
> on my system, header-line-format has a default value of
> nil. As far as I can tell, if a buffer's header-line-format
> value is modified to be non-nil a header is displayed -- so
> if a buffer starts out w/ a header-line-format value of nil
> and minor mode code modifies it to be non-nil, deactivation
> of the minor mode will cause the buffer to have an empty
> header line ("baggage").
>
> Is there a way to avoid this "baggage" using the idiomatic
> approach?
i see in dispextern.h that the macro WINDOW_WANTS_HEADER_LINE_P
only checks that `header-line-format' is non-nil; there is no
provision to conditionally display the header line based on its
contents.
thus, there is no way to use the same idiom as in the mode line,
as you have correctly surmised. thanks for motivating me to look
at the code more closely. probably you can lop off my part of
the thread thus far and replace it simply w/ "yes" as a response
to your original question, w/o incident.
thi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
[not found] ` <mailman.15408.1106746330.27204.help-gnu-emacs@gnu.org>
2005-01-26 14:12 ` Thien-Thi Nguyen
@ 2005-01-26 23:37 ` Kevin Rodgers
2005-01-30 23:32 ` ytrewq1
1 sibling, 1 reply; 15+ messages in thread
From: Kevin Rodgers @ 2005-01-26 23:37 UTC (permalink / raw)
ytrewq1 wrote:
>>more idiomatic is to have the minor mode define a variable
>>that has value nil when the minor mode is inactive. then,
>>you add the variable to the formatting tree unconditionally,
>>and the display engine takes care of things automatically.
>
> I don't think I quite follow you. Do you mean that the minor
> mode code should not be modifying header-line-format? If it's
> not supposed to, does that mean each user should add something
> to their .emacs to define header-line-format?
No. Instead of adding the value of foo-header-line-format to
header-line-format when the foo minor mode is turned on then removing it
when the mode is turned off, add the foo-header-line-format symbol
itself unconditionally when foo.el is loaded. foo-header-line-format
should be a buffer local variable whose default value is nil; turning
the mode on should set it to your desired display format; turning the
mode off should set it to back to nil.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
2005-01-26 23:37 ` Kevin Rodgers
@ 2005-01-30 23:32 ` ytrewq1
0 siblings, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-30 23:32 UTC (permalink / raw)
Kevin Rodgers writes:
> Instead of adding the value of foo-header-line-format to
> header-line-format when the foo minor mode is turned on then removing it
> when the mode is turned off, add the foo-header-line-format symbol
> itself unconditionally when foo.el is loaded. foo-header-line-format
> should be a buffer local variable whose default value is nil; turning
> the mode on should set it to your desired display format; turning the
> mode off should set it to back to nil.
Thanks for the explanation. I've posted a follow-up to one of ttn's recent
posts as it was similar and I encountered it earlier :-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
[not found] <mailman.15144.1106647267.27204.help-gnu-emacs@gnu.org>
2005-01-25 10:50 ` header-line-format hacking David Hansen
@ 2005-01-31 16:18 ` Stefan Monnier
2005-01-31 23:43 ` ytrewq1
[not found] ` <mailman.233.1107215940.2841.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2005-01-31 16:18 UTC (permalink / raw)
> Is there a recommended way to modify header-line-format? If possible, I'd
> like to augment an existing value (for cases where that makes sense)
> rather than override it. Grepping Emacs source, I've noticed a few places
> where it's overridden but haven't found an example of modification.
There are currently few uses of the header-line, and most of them seem to be
"global". I.e. either it's absent, or its content does not naturally lend
itself to being accompanied with some other info.
Could you give a couple examples of the kind of things you'd like to put/add
into the header-line?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: header-line-format hacking
2005-01-31 16:18 ` Stefan Monnier
@ 2005-01-31 23:43 ` ytrewq1
[not found] ` <mailman.233.1107215940.2841.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-31 23:43 UTC (permalink / raw)
Stefan Monnier writes:
> There are currently few uses of the header-line, and most of them seem to be
> "global". I.e. either it's absent, or its content does not naturally lend
> itself to being accompanied with some other info.
>
> Could you give a couple examples of the kind of things you'd like to put/add
> into the header-line?
I'm writing a couple of minor modes in which I'd like to express certain
'state' information and I'm not finding a whole lot of space in the
mode line on my system.
One minor mode attempts to display the current 'class' that point is in --
similar to what which-function-mode does for functions [1]. On my system,
there doesn't seem to be enough space to display this in the mode line --
especially when which-function-mode is active.
The other mode is for creating navigable annotated 'traces' through source
code. Roughly, a reader of some source code is provided with a way of
keeping notes as the flow of execution is traced. At the moment this
happens by selecting regions of text, indicating that a selected region
is a call or a definition, and optionally associating some text. The
created 'traces' may be navigated (e.g. move to root of trace, move to
next annotated point of execution, etc.), edited, and shared.
Anyway, I'd like to express the idea of 'trace has been modified' in a way
similar to what's currently done for 'buffer has been modified'. I'm also
thinking of expressing some other trace-related state information but I
wanted to see if I was able to work with header-line-format appropriately
before exploring the idea further.
Needless to say, I'd like to use both of these modes at the same time --
which is what prompted my question.
[1] In fact, which-class.el is essentially a modified which-func.el.
^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <mailman.233.1107215940.2841.help-gnu-emacs@gnu.org>]
* Re: header-line-format hacking
[not found] ` <mailman.233.1107215940.2841.help-gnu-emacs@gnu.org>
@ 2005-02-01 19:08 ` Stefan Monnier
0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2005-02-01 19:08 UTC (permalink / raw)
> One minor mode attempts to display the current 'class' that point is in --
> similar to what which-function-mode does for functions [1]. On my system,
> there doesn't seem to be enough space to display this in the mode line --
> especially when which-function-mode is active.
Hmm... I've used the <package>.<module>.<function> format in SML (by setting
which-func-functions) without any problem of mode-line space. But yes,
mode-line space can be hard to come by, especially if you have lots of
minor modes.
> Needless to say, I'd like to use both of these modes at the same time --
> which is what prompted my question.
I think you'll have to do it all by hand. Something like
(define-minor-mode my-foo-mode
"haha"
(cond
(my-foo-mode
(unless header-line-format (setq header-line-format '("")))
(add-to-list 'header-line-format 'my-foo-format 'append))
(t
(setq header-line-format (delq 'my-foo-format header-line-format))
(if (equal header-line-format '("")) (setq header-line-format nil)))))
-- Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* header-line-format hacking
@ 2005-01-25 9:30 ytrewq1
0 siblings, 0 replies; 15+ messages in thread
From: ytrewq1 @ 2005-01-25 9:30 UTC (permalink / raw)
Is there a recommended way to modify header-line-format? If possible, I'd like
to augment an existing value (for cases where that makes sense) rather than
override it. Grepping Emacs source, I've noticed a few places where it's
overridden but haven't found an example of modification.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2005-02-01 19:08 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.15144.1106647267.27204.help-gnu-emacs@gnu.org>
2005-01-25 10:50 ` header-line-format hacking David Hansen
2005-01-25 13:05 ` ytrewq1
[not found] ` <mailman.15179.1106660077.27204.help-gnu-emacs@gnu.org>
2005-01-25 18:49 ` Kevin Rodgers
2005-01-26 2:25 ` ytrewq1
[not found] ` <mailman.15337.1106708876.27204.help-gnu-emacs@gnu.org>
2005-01-26 11:04 ` Thien-Thi Nguyen
2005-01-26 13:09 ` ytrewq1
[not found] ` <mailman.15408.1106746330.27204.help-gnu-emacs@gnu.org>
2005-01-26 14:12 ` Thien-Thi Nguyen
2005-01-31 2:36 ` (apparently lost, so rewritten and reposted) " ytrewq1
[not found] ` <mailman.70.1107140500.2841.help-gnu-emacs@gnu.org>
2005-01-31 9:54 ` Thien-Thi Nguyen
2005-01-26 23:37 ` Kevin Rodgers
2005-01-30 23:32 ` ytrewq1
2005-01-31 16:18 ` Stefan Monnier
2005-01-31 23:43 ` ytrewq1
[not found] ` <mailman.233.1107215940.2841.help-gnu-emacs@gnu.org>
2005-02-01 19:08 ` Stefan Monnier
2005-01-25 9:30 ytrewq1
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.