help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extra info in modeline (tip and questions)


From: Nikolaj Schumacher
Subject: Re: Extra info in modeline (tip and questions)
Date: Wed, 15 Apr 2009 15:14:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (darwin)

Decebal <CLDWesterhof@gmail.com> wrote:

> The reason I put the closing parentheses on its own line, is that I
> find that more readable. I would even prefer:

It probably is.  I do it in C myself.  But with Lisp you have so many
parentheses that you lose too much vertical space.

The trick is to read the indentation instead of trying to mentally match
parentheses.  Since I got used to that I actually prefer the concise 
representation.

>> Also there are alternatives to updating the mode-line from a timer.
>> The mode-line supports a special :eval form with functions that are
>> called automatically, or you might update the values in
>> `after-change-functions'.
>
> Do you have any good pointers?

Just C-h v mode-line-format and C-h v after-change-functions.

For an :eval example see:
http://nschum.de/src/emacs/window-numbering-mode/
for hooks:
http://www.emacswiki.org/emacs-en/ChangeHook

> What I would like is that when I call the function interactively, that
> instead of returning the value, the value is displayed in the
> minibuffer. For this I need to know if the function is called
> interactively. If that is the case, I should do:
>     (message <return-value>)
> Is there a way to know if the function called interactively?

Well, there is `called-interactively-p', but I would just add another
parameter like this:

(defun test (beg end &optional verbose)
  (interactive "r\nd")
  (when verbose
    (message (buffer-substring beg end))))

> I also have another function where I need to input a boolean value
> interactively. At the moment I am doing this with n and use 0 for
> false and every other value for true. Is there a better way?

You can use `y-or-n-p' or `yes-or-no-p'.  But they don't have
characters in the interactive form.  So you need to do this:

(interactive (list (y-or-n-p "bool: ")))

Often the prefix-arg is perfect for boolean options, too.


regards,
Nikolaj Schumacher




reply via email to

[Prev in Thread] Current Thread [Next in Thread]