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

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

Re: interactive function calls


From: Nikolaj Schumacher
Subject: Re: interactive function calls
Date: Mon, 09 Jun 2008 18:46:27 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin)

Richard G Riley <address@hidden> wrote:

> I have this in my .emacs
>
> (define-key mode-specific-map [?F] 'fortune-from-region)
>
> The problem is that in the code for fortune-append we see something
> like:
>
> ,----
> |     (unless interactive
> |       (save-buffer)
> |       (if fortune-always-compile
> |       (fortune-compile file)))))
> | 
> `----
>
> Following a chat on #emacs on irc, I tried creating my own rgrfortune
> function which was then called from the key binding and then I was told
> it would call 'fortune-from-region "non interactively" - but this did not
> work

>From reading the code I gather that `interactive' in the code has
nothing to do with whether it is called interactively.  Rather,
`interactive' is an argument that is set to t by `fortune-from-region',
regardless if called interactively or not.

Here's the line from `fortune-from-region':

  (fortune-append string t file)
                         ^

So, working around that is not that easy.

> The reason I want it called "non interactive" is simply that thats
> the way to save and compile the fortune file as the fortune-append
> snippet above shows.

If I understand you correctly, couldn't you just call those lines
yourself?  Something like this...

(defun rgrfortune (beg end file)
  (interactive (list (region-beginning) (region-end)
                     (if current-prefix-arg (fortune-ask-file))))
  (fortune-from-region beg end file)
  (save-buffer)
  (fortune-compile file))


regards,
Nikolaj Schumacher




reply via email to

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