all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* interactive function calls
@ 2008-06-09  9:43 Richard G Riley
  2008-06-09 16:46 ` Nikolaj Schumacher
       [not found] ` <mailman.12949.1213029992.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Richard G Riley @ 2008-06-09  9:43 UTC (permalink / raw)
  To: help-gnu-emacs


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 e.g

,----
| (defun rgrfortune()
|   (fortune-from-region (region-beginning) (region-end) fortune-file))
| 
| (define-key mode-specific-map [?F] (lambda()(interactive)(rgrfortune)))
`----

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.

How to do it?





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

* Re: interactive function calls
  2008-06-09  9:43 interactive function calls Richard G Riley
@ 2008-06-09 16:46 ` Nikolaj Schumacher
       [not found] ` <mailman.12949.1213029992.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolaj Schumacher @ 2008-06-09 16:46 UTC (permalink / raw)
  To: Richard G Riley; +Cc: help-gnu-emacs

Richard G Riley <rileyrgdev@gmail.com> 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




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

* Re: interactive function calls
       [not found] ` <mailman.12949.1213029992.18990.help-gnu-emacs@gnu.org>
@ 2008-06-09 18:53   ` Richard G Riley
  0 siblings, 0 replies; 3+ messages in thread
From: Richard G Riley @ 2008-06-09 18:53 UTC (permalink / raw)
  To: help-gnu-emacs


Nikolaj Schumacher <n_schumacher@web.de> writes:

> Richard G Riley <rileyrgdev@gmail.com> 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

Aargh. I misread the code there. I was convinced it was something to do
with the interactive nature of calling code from a key bind.

Thanks - that worked fine.


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

end of thread, other threads:[~2008-06-09 18:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-09  9:43 interactive function calls Richard G Riley
2008-06-09 16:46 ` Nikolaj Schumacher
     [not found] ` <mailman.12949.1213029992.18990.help-gnu-emacs@gnu.org>
2008-06-09 18:53   ` Richard G Riley

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.