all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using passing the tempo-template user input to my function?
@ 2004-10-26 13:05 Hattuari
  2004-10-26 15:49 ` Kevin Rodgers
  2004-10-27 17:23 ` Vagn Johansen
  0 siblings, 2 replies; 10+ messages in thread
From: Hattuari @ 2004-10-26 13:05 UTC (permalink / raw)


I've tried all the ways I can come up with to pass the string returned from
querying the user to my own function.  I know the string is there, I can
paste it into the text at the point where I'm trying to paste a modified
version.

This is an example of code that pastes the original user text:

(tempo-define-template
 "array"
 '("typedef array<"
   (P "Data type: " data-type)
   ","
   (P "Number of components: 1 to 4 " data-order)
   "> Array" (s data-type)))
;;

Variations such as the following don't work:

;; this does not produce an error message, but fails to produce the intended
;; result.
"> Array" (plist-get paste-data-type-map (tempo-lookup-named 'data-type))))

;; This produces errors whether data-type is quoted or not.
"> Array" (plist-get paste-data-type-map (s 'data-type))))

If I explicitly pass the correct string to the function, the correct output
is generated.  Suggestions?
-- 
p->m == (*p).m == p[0].m

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-26 13:05 Using passing the tempo-template user input to my function? Hattuari
@ 2004-10-26 15:49 ` Kevin Rodgers
  2004-10-27  6:15   ` Hattuari
  2004-10-27 17:23 ` Vagn Johansen
  1 sibling, 1 reply; 10+ messages in thread
From: Kevin Rodgers @ 2004-10-26 15:49 UTC (permalink / raw)


Hattuari wrote:
 > I've tried all the ways I can come up with to pass the string 
returned from
 > querying the user to my own function.  I know the string is there, I can
 > paste it into the text at the point where I'm trying to paste a modified
 > version.
 >
 > This is an example of code that pastes the original user text:
 >
 > (tempo-define-template
 >  "array"
 >  '("typedef array<"
 >    (P "Data type: " data-type)
 >    ","
 >    (P "Number of components: 1 to 4 " data-order)
 >    "> Array" (s data-type)))
 > ;;

,----[ C-h f tempo-define-template RET ]
| tempo-define-template is a compiled Lisp function in `tempo'.
| (tempo-define-template NAME ELEMENTS &optional TAG DOCUMENTATION TAGLIST)
|
| Define a template.
| This function creates a template variable `tempo-template-NAME' and an
| interactive function `tempo-template-NAME' that inserts the template
| at the point.  The created function is returned.
...
| The elements in ELEMENTS can be of several types:
...
|  - The symbol 'p. This position is saved in `tempo-marks'.
...
|  - (p PROMPT <NAME> <NOINSERT>) If `tempo-interactive' is non-nil, the
|    user is prompted in the minbuffer with PROMPT for a string to be
|    inserted. If the optional parameter NAME is non-nil, the text is
|    saved for later insertion with the `s' tag. If there already is
|    something saved under NAME that value is used instead and no
|    prompting is made. If NOINSERT is provided and non-nil, nothing is
|    inserted, but text is still saved when a NAME is provided. For
|    clarity, the symbol 'noinsert should be used as argument.
|  - (P PROMPT <NAME> <NOINSERT>) Works just like the previous tag, but
|    forces tempo-interactive to be true.
...
|  - (s NAME) Inserts text previously read with the (p ..) construct.
|    Finds the insertion saved under NAME and inserts it. Acts like 'p
|    if tempo-interactive is nil.
...

If tempo-interactive is nil, perhaps you need to do something like

(let ((tempo-interactive t))
   (tempo-define-template ...))

which would also allow you to use (p ...) instead of (P ...) in your 
template.

-- 
Kevin Rodgers

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-26 15:49 ` Kevin Rodgers
@ 2004-10-27  6:15   ` Hattuari
  2004-10-27 16:59     ` Hattuari
  0 siblings, 1 reply; 10+ messages in thread
From: Hattuari @ 2004-10-27  6:15 UTC (permalink / raw)


Kevin Rodgers wrote:


> If tempo-interactive is nil, perhaps you need to do something like
> 
> (let ((tempo-interactive t))
>    (tempo-define-template ...))
> 
> which would also allow you to use (p ...) instead of (P ...) in your
> template.
> 

The user is prompted for input.  The input is available for insertion using
s NAME.  My question is how do I use the value returned by s NAME in my own
function?
-- 
p->m == (*p).m == p[0].m

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-27  6:15   ` Hattuari
@ 2004-10-27 16:59     ` Hattuari
  2004-10-31 15:22       ` Kai Grossjohann
       [not found]       ` <mailman.6359.1099233079.2017.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Hattuari @ 2004-10-27 16:59 UTC (permalink / raw)


Hattuari wrote:

> Kevin Rodgers wrote:
> 
> 
>> If tempo-interactive is nil, perhaps you need to do something like
>> 
>> (let ((tempo-interactive t))
>>    (tempo-define-template ...))
>> 
>> which would also allow you to use (p ...) instead of (P ...) in your
>> template.
>> 
> 
> The user is prompted for input.  The input is available for insertion
> using
> s NAME.  My question is how do I use the value returned by s NAME in my
> own function?
Well, at least I can refine my question based on further understanding.  My
mistake is trying to compare the string "GLbyte" with the symbol 'GLbyte. 
These are distinct objects with unrelated values.  What I should probably
be doing is providing the user with a picklist of symbols to chose from. 
Is there a way to do that?
-- 
p->m == (*p).m == p[0].m

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-26 13:05 Using passing the tempo-template user input to my function? Hattuari
  2004-10-26 15:49 ` Kevin Rodgers
@ 2004-10-27 17:23 ` Vagn Johansen
  2004-10-30 12:11   ` Hattuari
  1 sibling, 1 reply; 10+ messages in thread
From: Vagn Johansen @ 2004-10-27 17:23 UTC (permalink / raw)


Hattuari <susudata@setidava.kushan.aa> writes:

> I've tried all the ways I can come up with to pass the string returned from
> querying the user to my own function.  

[...]

> If I explicitly pass the correct string to the function, the correct output
> is generated.  Suggestions?

Use your own query-function and a global variable. 

For example

    (defvar xyz-name nil)

    (defun xyz-read ()
        (interactive)
        (setq xyz-name (read-from-minibuffer "xyz-name? ")))

    (defun xyz-func ()
        (upcase xyz-name))

    (tempo-define-template "xyz" 
        '("xyz { " (xyz-read) " } { " 'xyz-name " } { " (xyz-func) " }" )
        "xyz" "desc" 'elisp-tempo-tags)

-- 
Vagn Johansen

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-27 17:23 ` Vagn Johansen
@ 2004-10-30 12:11   ` Hattuari
  0 siblings, 0 replies; 10+ messages in thread
From: Hattuari @ 2004-10-30 12:11 UTC (permalink / raw)


Vagn Johansen wrote:

> Hattuari <susudata@setidava.kushan.aa> writes:
> 
>> I've tried all the ways I can come up with to pass the string returned
>> from querying the user to my own function.
> 
> [...]
> 
>> If I explicitly pass the correct string to the function, the correct
>> output
>> is generated.  Suggestions?
> 
> Use your own query-function and a global variable.
> 
> For example
> 
>     (defvar xyz-name nil)
> 
>     (defun xyz-read ()
>         (interactive)
>         (setq xyz-name (read-from-minibuffer "xyz-name? ")))
> 
>     (defun xyz-func ()
>         (upcase xyz-name))
> 
>     (tempo-define-template "xyz"
>         '("xyz { " (xyz-read) " } { " 'xyz-name " } { " (xyz-func) " }" )
>         "xyz" "desc" 'elisp-tempo-tags)
> 

I just wanted to let you know I didn't ignore this.  I did look at the code
you posted, and tried a few variations.  The reason I'm exploring
alternative approaches is that I simply came to the conclusion that I need
to work on the fundamentals of Lisp a bit more.  I've been stabbing in the
dark at my .emacs for years without really understanding what I'm doing.
I've wasted a lot of time trying to accomplish 'simple' things because I
didn't know what I was doing.
-- 
p->m == (*p).m == p[0].m

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-27 16:59     ` Hattuari
@ 2004-10-31 15:22       ` Kai Grossjohann
       [not found]       ` <mailman.6359.1099233079.2017.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Kai Grossjohann @ 2004-10-31 15:22 UTC (permalink / raw)


Hattuari <susudata@setidava.kushan.aa> writes:

> Well, at least I can refine my question based on further
> understanding.  My mistake is trying to compare the string "GLbyte"
> with the symbol 'GLbyte.  These are distinct objects with unrelated
> values.  What I should probably be doing is providing the user with
> a picklist of symbols to chose from.  Is there a way to do that?

The normal Emacs way to do this by reading it from the minibuffer with
completion.  See the function completing-read.

Kai

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

* Re: Using passing the tempo-template user input to my function?
       [not found]       ` <mailman.6359.1099233079.2017.help-gnu-emacs@gnu.org>
@ 2004-10-31 16:02         ` Hattuari
       [not found]           ` <mailman.6437.1099256821.2017.help-gnu-emacs@gnu.org>
  2004-10-31 21:56           ` Kai Grossjohann
  0 siblings, 2 replies; 10+ messages in thread
From: Hattuari @ 2004-10-31 16:02 UTC (permalink / raw)


Kai Grossjohann wrote:

> The normal Emacs way to do this by reading it from the minibuffer with
> completion.  See the function completing-read.
> 
> Kai

That's pretty much what I'm shooting for.  What I want is to prompt the
reader for a series of responses, the first being of the form 'GL<type>'
where <type> is selected from a pick list.  The next will be an integer in
the range 1 through 4. And the last value will be boolean, preferably with
some mnemonic representation indicating its meaning.  I've looked at
completing-read and completing-read-multiple.  I wasn't able to figure out
how to use the latter.  

I haven't directly revisited the topic because I want to finish reading the
preceeding sections of the Reference Manual. And because someone who's IP
address traced to a Redhat linux box in Japan discovered a way to attach to
several of my highports with ssh and gain access to my system...  I was
forced to reinstall since I couldn't upgrade from the very ancient version
of SuSE Linux I was running on the server. 
-- 
p->m == (*p).m == p[0].m

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

* Re: Using passing the tempo-template user input to my function?
       [not found]           ` <mailman.6437.1099256821.2017.help-gnu-emacs@gnu.org>
@ 2004-10-31 21:46             ` Hattuari
  0 siblings, 0 replies; 10+ messages in thread
From: Hattuari @ 2004-10-31 21:46 UTC (permalink / raw)


Kai Grossjohann wrote:

> Hattuari <susudata@setidava.kushan.aa> writes:
> 
>> That's pretty much what I'm shooting for.  What I want is to prompt the
>> reader for a series of responses, the first being of the form 'GL<type>'
>> where <type> is selected from a pick list.  The next will be an integer
>> in the range 1 through 4. And the last value will be boolean, preferably
>> with
>> some mnemonic representation indicating its meaning.  I've looked at
>> completing-read and completing-read-multiple.  I wasn't able to figure
>> out how to use the latter.
> 
> Perhaps the easiest method to read a boolean is y-or-n-p.  Is this
> what you mean by "latter"?
> 
> Kai
I meant completing-read-multiple. I'll have to look at it again before I can
formulate any specific questions. 
-- 
p->m == (*p).m == p[0].m

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

* Re: Using passing the tempo-template user input to my function?
  2004-10-31 16:02         ` Hattuari
       [not found]           ` <mailman.6437.1099256821.2017.help-gnu-emacs@gnu.org>
@ 2004-10-31 21:56           ` Kai Grossjohann
  1 sibling, 0 replies; 10+ messages in thread
From: Kai Grossjohann @ 2004-10-31 21:56 UTC (permalink / raw)


Hattuari <susudata@setidava.kushan.aa> writes:

> That's pretty much what I'm shooting for.  What I want is to prompt the
> reader for a series of responses, the first being of the form 'GL<type>'
> where <type> is selected from a pick list.  The next will be an integer in
> the range 1 through 4. And the last value will be boolean, preferably with
> some mnemonic representation indicating its meaning.  I've looked at
> completing-read and completing-read-multiple.  I wasn't able to figure out
> how to use the latter.  

Perhaps the easiest method to read a boolean is y-or-n-p.  Is this
what you mean by "latter"?

Kai

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

end of thread, other threads:[~2004-10-31 21:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-26 13:05 Using passing the tempo-template user input to my function? Hattuari
2004-10-26 15:49 ` Kevin Rodgers
2004-10-27  6:15   ` Hattuari
2004-10-27 16:59     ` Hattuari
2004-10-31 15:22       ` Kai Grossjohann
     [not found]       ` <mailman.6359.1099233079.2017.help-gnu-emacs@gnu.org>
2004-10-31 16:02         ` Hattuari
     [not found]           ` <mailman.6437.1099256821.2017.help-gnu-emacs@gnu.org>
2004-10-31 21:46             ` Hattuari
2004-10-31 21:56           ` Kai Grossjohann
2004-10-27 17:23 ` Vagn Johansen
2004-10-30 12:11   ` Hattuari

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.