all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Passing a list of symbols to function argument
@ 2024-11-29 17:34 Heime via Users list for the GNU Emacs text editor
  2024-11-29 19:54 ` Stephen Berman
  0 siblings, 1 reply; 9+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-29 17:34 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Why do I get 

   Wrong type argument: stringp, tabtrail

When using the call 

   (poalatuk '(72 tabtrail global))

to the function


(defun poalatuk (actm-seqr)

  (interactive
    (let* ( (colw (read-number "Line Column: " 72))
            (cseq '("extended" "disable" "tabtrail"))
            (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
            (scope (completing-read "Scope: "
                     '("global" "local") nil t "local")) )

      ;; Pass a single list as argument
      (list (list colw rsel scope))) )

  ;; -------------------------------------------------------------

  (message "poalatuk: %S" actm-seqr)

  (let* ( (colw (nth 0 actm-seqr))              ;; Extract column width.
          (rsel (intern (nth 1 actm-seqr)))     ;; Extract mode selector.
          (scope (intern (nth 2 actm-seqr))) )  ;; Extract scope.

    (require 'whitespace)

    (if (eq scope 'global)
          (global-whitespace-mode 0)
      (whitespace-mode 0))

    (pcase rsel

      ('tabtrail
         (setq whitespace-line-column (or colw 72))
         (setq whitespace-style
                '(face tabs tab-mark trailing lines-char))
         (if (eq scope 'global)
               (global-whitespace-mode 1)
           (whitespace-mode 1)))

      ('extended
         (setq whitespace-line-column (or colw 72))
         (setq whitespace-style
                '(face tabs tab-mark indentation trailing lines-char
                  space-before-tab space-after-tab))
         (if (eq scope 'global)
               (global-whitespace-mode 1)
           (whitespace-mode 1)) )

      ('disable
         (if (eq scope 'global)
               (global-whitespace-mode 0)
           (whitespace-mode 0)) )) ))

I want to pass alist as an argument to the function such as
   
   (poalatuk '(72 tabtrail global))

And expecting that actm-seqr would be alist.



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

* Re: Passing a list of symbols to function argument
  2024-11-29 17:34 Passing a list of symbols to function argument Heime via Users list for the GNU Emacs text editor
@ 2024-11-29 19:54 ` Stephen Berman
  2024-11-29 20:15   ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2024-11-29 19:54 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor; +Cc: Heime

On Fri, 29 Nov 2024 17:34:01 +0000 Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Why do I get
>
>    Wrong type argument: stringp, tabtrail
>
> When using the call
>
>    (poalatuk '(72 tabtrail global))
>
> to the function
>
>
> (defun poalatuk (actm-seqr)
>
>   (interactive
>     (let* ( (colw (read-number "Line Column: " 72))
>             (cseq '("extended" "disable" "tabtrail"))
>             (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
>             (scope (completing-read "Scope: "
>                      '("global" "local") nil t "local")) )
>
>       ;; Pass a single list as argument
>       (list (list colw rsel scope))) )
>
>   ;; -------------------------------------------------------------
>
>   (message "poalatuk: %S" actm-seqr)
>
>   (let* ( (colw (nth 0 actm-seqr))              ;; Extract column width.
>           (rsel (intern (nth 1 actm-seqr)))     ;; Extract mode selector.
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^

The error happens here.  You passed '(72 tabtrail global) as the value
of the argument actm-seqr, so (nth 1 actm-seqr) returns the symbol
`tabtrail'.  But `intern' takes a string and returns the symbol (in the
obarray) whose name is given by the string.

Steve Berman



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

* Re: Passing a list of symbols to function argument
  2024-11-29 19:54 ` Stephen Berman
@ 2024-11-29 20:15   ` Heime via Users list for the GNU Emacs text editor
  2024-11-29 20:41     ` Stephen Berman
  0 siblings, 1 reply; 9+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-29 20:15 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Saturday, November 30th, 2024 at 7:54 AM, Stephen Berman <stephen.berman@gmx.net> wrote:

> On Fri, 29 Nov 2024 17:34:01 +0000 Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org wrote:
> 
> > Why do I get
> > 
> > Wrong type argument: stringp, tabtrail
> > 
> > When using the call
> > 
> > (poalatuk '(72 tabtrail global))
> > 
> > to the function
> > 
> > (defun poalatuk (actm-seqr)
> > 
> > (interactive
> > (let* ( (colw (read-number "Line Column: " 72))
> > (cseq '("extended" "disable" "tabtrail"))
> > (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
> > (scope (completing-read "Scope: "
> > '("global" "local") nil t "local")) )
> > 
> > ;; Pass a single list as argument
> > (list (list colw rsel scope))) )
> > 
> > ;; -------------------------------------------------------------
> > 
> > (message "poalatuk: %S" actm-seqr)
> > 
> > (let* ( (colw (nth 0 actm-seqr)) ;; Extract column width.
> > (rsel (intern (nth 1 actm-seqr))) ;; Extract mode selector.
> 
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> The error happens here. You passed '(72 tabtrail global) as the value
> of the argument actm-seqr, so (nth 1 actm-seqr) returns the symbol
> `tabtrail'. But` intern' takes a string and returns the symbol (in the
> obarray) whose name is given by the string.
> 
> Steve Berman

I want the function to accept both symbols and strings.  intern must then 
be applied only when a string is passed.  Which undoubtedly needs a conditional
check.

Perhaps I should also test whether the argument is a symbol or do the if
and pcase handle errors (because the commands will be skipped).

(let* ((colw (nth 0 actm-seqr))
       (rsel (if (stringp (nth 1 actm-seqr)) 
                 (intern (nth 1 actm-seqr))
               (nth 1 actm-seqr)))
       (scope (if (stringp (nth 2 actm-seqr)) 
                  (intern (nth 2 actm-seqr))
                (nth 2 actm-seqr))))



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

* Re: Passing a list of symbols to function argument
  2024-11-29 20:15   ` Heime via Users list for the GNU Emacs text editor
@ 2024-11-29 20:41     ` Stephen Berman
  2024-11-29 21:16       ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2024-11-29 20:41 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Fri, 29 Nov 2024 20:15:04 +0000 Heime <heimeborgia@protonmail.com> wrote:

> Sent with Proton Mail secure email.
>
> On Saturday, November 30th, 2024 at 7:54 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>> On Fri, 29 Nov 2024 17:34:01 +0000 Heime via Users list for the GNU Emacs
>> text editor help-gnu-emacs@gnu.org wrote:
>>
>> > Why do I get
>> >
>> > Wrong type argument: stringp, tabtrail
>> >
>> > When using the call
>> >
>> > (poalatuk '(72 tabtrail global))
>> >
>> > to the function
>> >
>> > (defun poalatuk (actm-seqr)
>> >
>> > (interactive
>> > (let* ( (colw (read-number "Line Column: " 72))
>> > (cseq '("extended" "disable" "tabtrail"))
>> > (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
>> > (scope (completing-read "Scope: "
>> > '("global" "local") nil t "local")) )
>> >
>> > ;; Pass a single list as argument
>> > (list (list colw rsel scope))) )
>> >
>> > ;; -------------------------------------------------------------
>> >
>> > (message "poalatuk: %S" actm-seqr)
>> >
>> > (let* ( (colw (nth 0 actm-seqr)) ;; Extract column width.
>> > (rsel (intern (nth 1 actm-seqr))) ;; Extract mode selector.
>>
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> The error happens here. You passed '(72 tabtrail global) as the value
>> of the argument actm-seqr, so (nth 1 actm-seqr) returns the symbol
>> `tabtrail'. But` intern' takes a string and returns the symbol (in the
>> obarray) whose name is given by the string.
>>
>> Steve Berman
>
> I want the function to accept both symbols and strings.  intern must then
> be applied only when a string is passed.  Which undoubtedly needs a conditional
> check.
>
> Perhaps I should also test whether the argument is a symbol or do the if
> and pcase handle errors (because the commands will be skipped).
>
> (let* ((colw (nth 0 actm-seqr))
>        (rsel (if (stringp (nth 1 actm-seqr))
>                  (intern (nth 1 actm-seqr))
>                (nth 1 actm-seqr)))
>        (scope (if (stringp (nth 2 actm-seqr))
>                   (intern (nth 2 actm-seqr))
>                 (nth 2 actm-seqr))))

This seems fine; `if' does not do error handling, nor does `pcase' AFAIK
(but there are several variants and extensions of pcase, and I'm not too
familiar with them, so maybe some of them do error handling), but
`condition-case' is the basic error handling form in Elisp.
Alternatively, since the error only happens in noninteractive calls
(since interactive calls use `completing-read', which returns strings),
you could condition on `called-interactively-p'.

Steve Berman



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

* Re: Passing a list of symbols to function argument
  2024-11-29 20:41     ` Stephen Berman
@ 2024-11-29 21:16       ` Heime via Users list for the GNU Emacs text editor
  2024-11-29 21:29         ` Stephen Berman
  0 siblings, 1 reply; 9+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-29 21:16 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

On Saturday, November 30th, 2024 at 8:41 AM, Stephen Berman <stephen.berman@gmx.net> wrote:

> On Fri, 29 Nov 2024 20:15:04 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > On Saturday, November 30th, 2024 at 7:54 AM, Stephen Berman
> > stephen.berman@gmx.net wrote:
> > 
> > > On Fri, 29 Nov 2024 17:34:01 +0000 Heime via Users list for the GNU Emacs
> > > text editor help-gnu-emacs@gnu.org wrote:
> > > 
> > > > Why do I get
> > > > 
> > > > Wrong type argument: stringp, tabtrail
> > > > 
> > > > When using the call
> > > > 
> > > > (poalatuk '(72 tabtrail global))
> > > > 
> > > > to the function
> > > > 
> > > > (defun poalatuk (actm-seqr)
> > > > 
> > > > (interactive
> > > > (let* ( (colw (read-number "Line Column: " 72))
> > > > (cseq '("extended" "disable" "tabtrail"))
> > > > (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
> > > > (scope (completing-read "Scope: "
> > > > '("global" "local") nil t "local")) )
> > > > 
> > > > ;; Pass a single list as argument
> > > > (list (list colw rsel scope))) )
> > > > 
> > > > ;; -------------------------------------------------------------
> > > > 
> > > > (message "poalatuk: %S" actm-seqr)
> > > > 
> > > > (let* ( (colw (nth 0 actm-seqr)) ;; Extract column width.
> > > > (rsel (intern (nth 1 actm-seqr))) ;; Extract mode selector.
> > > 
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > 
> > > The error happens here. You passed '(72 tabtrail global) as the value
> > > of the argument actm-seqr, so (nth 1 actm-seqr) returns the symbol
> > > `tabtrail'. But` intern' takes a string and returns the symbol (in the
> > > obarray) whose name is given by the string.
> > > 
> > > Steve Berman
> > 
> > I want the function to accept both symbols and strings. intern must then
> > be applied only when a string is passed. Which undoubtedly needs a conditional
> > check.
> > 
> > Perhaps I should also test whether the argument is a symbol or do the if
> > and pcase handle errors (because the commands will be skipped).
> > 
> > (let* ((colw (nth 0 actm-seqr))
> > (rsel (if (stringp (nth 1 actm-seqr))
> > (intern (nth 1 actm-seqr))
> > (nth 1 actm-seqr)))
> > (scope (if (stringp (nth 2 actm-seqr))
> > (intern (nth 2 actm-seqr))
> > (nth 2 actm-seqr))))
> 
> 
> This seems fine; `if' does not do error handling, nor does` pcase' AFAIK
> (but there are several variants and extensions of pcase, and I'm not too
> familiar with them, so maybe some of them do error handling), but
> `condition-case' is the basic error handling form in Elisp. Alternatively, since the error only happens in noninteractive calls (since interactive calls use` completing-read', which returns strings),
> you could condition on `called-interactively-p'.
> 
> Steve Berman

For the interactive call I want to pass the three values so that
actm-seqr will be a list of three objects.

Thus I do 

   (list (list colw rsel scope))

Would the above be correct?

With only (list colw rsel scope) emacs does complain.

I wonder whether actm-seqr will give me ((72 tabtrail global))
and not (72 tabtrail global).

Have also been looking at the possibility of using

   (list (list colw (intern rsel) (intern scope)))

Or would this be considered replication?  Because the call
to intern would happen later anyway.





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

* Re: Passing a list of symbols to function argument
  2024-11-29 21:16       ` Heime via Users list for the GNU Emacs text editor
@ 2024-11-29 21:29         ` Stephen Berman
  2024-11-29 21:41           ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2024-11-29 21:29 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Fri, 29 Nov 2024 21:16:09 +0000 Heime <heimeborgia@protonmail.com> wrote:

> On Saturday, November 30th, 2024 at 8:41 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>> On Fri, 29 Nov 2024 20:15:04 +0000 Heime heimeborgia@protonmail.com wrote:
>>
>> > On Saturday, November 30th, 2024 at 7:54 AM, Stephen Berman
>> > stephen.berman@gmx.net wrote:
>> >
>> > > On Fri, 29 Nov 2024 17:34:01 +0000 Heime via Users list for the GNU Emacs
>> > > text editor help-gnu-emacs@gnu.org wrote:
>> > >
>> > > > Why do I get
>> > > >
>> > > > Wrong type argument: stringp, tabtrail
>> > > >
>> > > > When using the call
>> > > >
>> > > > (poalatuk '(72 tabtrail global))
>> > > >
>> > > > to the function
>> > > >
>> > > > (defun poalatuk (actm-seqr)
>> > > >
>> > > > (interactive
>> > > > (let* ( (colw (read-number "Line Column: " 72))
>> > > > (cseq '("extended" "disable" "tabtrail"))
>> > > > (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
>> > > > (scope (completing-read "Scope: "
>> > > > '("global" "local") nil t "local")) )
>> > > >
>> > > > ;; Pass a single list as argument
>> > > > (list (list colw rsel scope))) )
>> > > >
>> > > > ;; -------------------------------------------------------------
>> > > >
>> > > > (message "poalatuk: %S" actm-seqr)
>> > > >
>> > > > (let* ( (colw (nth 0 actm-seqr)) ;; Extract column width.
>> > > > (rsel (intern (nth 1 actm-seqr))) ;; Extract mode selector.
>> > >
>> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^
>> > >
>> > > The error happens here. You passed '(72 tabtrail global) as the value
>> > > of the argument actm-seqr, so (nth 1 actm-seqr) returns the symbol
>> > > `tabtrail'. But` intern' takes a string and returns the symbol (in the
>> > > obarray) whose name is given by the string.
>> > >
>> > > Steve Berman
>> >
>> > I want the function to accept both symbols and strings. intern must then
>> > be applied only when a string is passed. Which undoubtedly needs a conditional
>> > check.
>> >
>> > Perhaps I should also test whether the argument is a symbol or do the if
>> > and pcase handle errors (because the commands will be skipped).
>> >
>> > (let* ((colw (nth 0 actm-seqr))
>> > (rsel (if (stringp (nth 1 actm-seqr))
>> > (intern (nth 1 actm-seqr))
>> > (nth 1 actm-seqr)))
>> > (scope (if (stringp (nth 2 actm-seqr))
>> > (intern (nth 2 actm-seqr))
>> > (nth 2 actm-seqr))))
>>
>>
>> This seems fine; `if' does not do error handling, nor does` pcase' AFAIK
>> (but there are several variants and extensions of pcase, and I'm not too
>> familiar with them, so maybe some of them do error handling), but
>> `condition-case' is the basic error handling form in Elisp. Alternatively,
>> since the error only happens in noninteractive calls (since interactive
>> calls use` completing-read', which returns strings),
>> you could condition on `called-interactively-p'.
>>
>> Steve Berman
>
> For the interactive call I want to pass the three values so that
> actm-seqr will be a list of three objects.
>
> Thus I do
>
>    (list (list colw rsel scope))
>
> Would the above be correct?

Yes.

> With only (list colw rsel scope) emacs does complain.

Because that means the interactive call passes three arguments, but your
definition of `poalatuk' only specifies one argument parameter.

> I wonder whether actm-seqr will give me ((72 tabtrail global))
> and not (72 tabtrail global).

I don't know what you mean; actm-seqr is the function parameter, a
variable whose value is whatever is passed on calling the function
either interactively or noninteractively.

> Have also been looking at the possibility of using
>
>    (list (list colw (intern rsel) (intern scope)))
>
> Or would this be considered replication?  Because the call
> to intern would happen later anyway.

Then it would cause the error you reported in your OP.

Steve Berman



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

* Re: Passing a list of symbols to function argument
  2024-11-29 21:29         ` Stephen Berman
@ 2024-11-29 21:41           ` Heime via Users list for the GNU Emacs text editor
  2024-11-29 21:52             ` Stephen Berman
  0 siblings, 1 reply; 9+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-29 21:41 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor


On Saturday, November 30th, 2024 at 9:29 AM, Stephen Berman <stephen.berman@gmx.net> wrote:

> > > > I want the function to accept both symbols and strings. intern must then
> > > > be applied only when a string is passed. Which undoubtedly needs a conditional
> > > > check.
> > > > 
> > > > Perhaps I should also test whether the argument is a symbol or do the if
> > > > and pcase handle errors (because the commands will be skipped).
> > > > 
> > > > (let* ((colw (nth 0 actm-seqr))
> > > > (rsel (if (stringp (nth 1 actm-seqr))
> > > > (intern (nth 1 actm-seqr))
> > > > (nth 1 actm-seqr)))
> > > > (scope (if (stringp (nth 2 actm-seqr))
> > > > (intern (nth 2 actm-seqr))
> > > > (nth 2 actm-seqr))))
> > > 
> > > This seems fine; `if' does not do error handling, nor does` pcase' AFAIK
> > > (but there are several variants and extensions of pcase, and I'm not too
> > > familiar with them, so maybe some of them do error handling), but
> > > `condition-case' is the basic error handling form in Elisp. Alternatively, since the error only happens in noninteractive calls (since interactive calls use` completing-read', which returns strings),
> > > you could condition on `called-interactively-p'.
> > > 
> > > Steve Berman
> > 
> > For the interactive call I want to pass the three values so that
> > actm-seqr will be a list of three objects.
> > 
> > Thus I do
> > 
> > (list (list colw rsel scope))
> > 
> > Would the above be correct?
> 
> 
> Yes.
> 
> > With only (list colw rsel scope) emacs does complain.
> 
> 
> Because that means the interactive call passes three arguments, but your
> definition of `poalatuk' only specifies one argument parameter.
> 
> > I wonder whether actm-seqr will give me ((72 tabtrail global))
> > and not (72 tabtrail global).
> 
> I don't know what you mean; actm-seqr is the function parameter, a
> variable whose value is whatever is passed on calling the function
> either interactively or noninteractively.

For the interactive part, would returning

   (list (list colw (intern rsel) (intern scope)))

pass

   ((72 tabtrail global))  ; list with single element being a list

or 

  (72 tabtrail global)  ; list of three entries

to actm-seqr?
 
> > Have also been looking at the possibility of using
> > 
> > (list (list colw (intern rsel) (intern scope)))
> > 
> > Or would this be considered replication? Because the call
> > to intern would happen later anyway.
> 
> Then it would cause the error you reported in your OP.

   (list (list colw (intern rsel) (intern scope)))

The above will be for the interactive part, so that the string values
would be changed immediately to symbols.

And since I now fixed the problem by checking with stringp so intern gets
called when calling the function programatically with strings.







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

* Re: Passing a list of symbols to function argument
  2024-11-29 21:41           ` Heime via Users list for the GNU Emacs text editor
@ 2024-11-29 21:52             ` Stephen Berman
  2024-11-29 22:45               ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2024-11-29 21:52 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Fri, 29 Nov 2024 21:41:27 +0000 Heime <heimeborgia@protonmail.com> wrote:

> On Saturday, November 30th, 2024 at 9:29 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>> > > > I want the function to accept both symbols and strings. intern must then
>> > > > be applied only when a string is passed. Which undoubtedly needs a
>> > > > conditional
>> > > > check.
>> > > >
>> > > > Perhaps I should also test whether the argument is a symbol or do the if
>> > > > and pcase handle errors (because the commands will be skipped).
>> > > >
>> > > > (let* ((colw (nth 0 actm-seqr))
>> > > > (rsel (if (stringp (nth 1 actm-seqr))
>> > > > (intern (nth 1 actm-seqr))
>> > > > (nth 1 actm-seqr)))
>> > > > (scope (if (stringp (nth 2 actm-seqr))
>> > > > (intern (nth 2 actm-seqr))
>> > > > (nth 2 actm-seqr))))
>> > >
>> > > This seems fine; `if' does not do error handling, nor does` pcase' AFAIK
>> > > (but there are several variants and extensions of pcase, and I'm not too
>> > > familiar with them, so maybe some of them do error handling), but
>> > > `condition-case' is the basic error handling form in
>> > > Elisp. Alternatively, since the error only happens in noninteractive
>> > > calls (since interactive calls use` completing-read', which returns
>> > > strings),
>> > > you could condition on `called-interactively-p'.
>> > >
>> > > Steve Berman
>> >
>> > For the interactive call I want to pass the three values so that
>> > actm-seqr will be a list of three objects.
>> >
>> > Thus I do
>> >
>> > (list (list colw rsel scope))
>> >
>> > Would the above be correct?
>>
>>
>> Yes.
>>
>> > With only (list colw rsel scope) emacs does complain.
>>
>>
>> Because that means the interactive call passes three arguments, but your
>> definition of `poalatuk' only specifies one argument parameter.
>>
>> > I wonder whether actm-seqr will give me ((72 tabtrail global))
>> > and not (72 tabtrail global).
>>
>> I don't know what you mean; actm-seqr is the function parameter, a
>> variable whose value is whatever is passed on calling the function
>> either interactively or noninteractively.
>
> For the interactive part, would returning
>
>    (list (list colw (intern rsel) (intern scope)))
>
> pass
>
>    ((72 tabtrail global))  ; list with single element being a list
>
> or
>
>   (72 tabtrail global)  ; list of three entries
>
> to actm-seqr?

The answer is in message displayed when you do `M-x poalatuk' and act
appropriately on the prompts, isn't it?

>> > Have also been looking at the possibility of using
>> >
>> > (list (list colw (intern rsel) (intern scope)))
>> >
>> > Or would this be considered replication? Because the call
>> > to intern would happen later anyway.
>>
>> Then it would cause the error you reported in your OP.
>
>    (list (list colw (intern rsel) (intern scope)))
>
> The above will be for the interactive part, so that the string values
> would be changed immediately to symbols.
>
> And since I now fixed the problem by checking with stringp so intern gets
> called when calling the function programatically with strings.

Ok.

Steve Berman



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

* Re: Passing a list of symbols to function argument
  2024-11-29 21:52             ` Stephen Berman
@ 2024-11-29 22:45               ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 9+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-29 22:45 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

> > > > For the interactive call I want to pass the three values so that
> > > > actm-seqr will be a list of three objects.
> > > > 
> > > > Thus I do
> > > > 
> > > > (list (list colw rsel scope))
> > > > 
> > > > Would the above be correct?
> > > 
> > > Yes.
> > > 
> > > > With only (list colw rsel scope) emacs does complain.
> > > 
> > > Because that means the interactive call passes three arguments, but your
> > > definition of `poalatuk' only specifies one argument parameter.
> > > 
> > > > I wonder whether actm-seqr will give me ((72 tabtrail global))
> > > > and not (72 tabtrail global).
> > > 
> > > I don't know what you mean; actm-seqr is the function parameter, a
> > > variable whose value is whatever is passed on calling the function
> > > either interactively or noninteractively.
> > 
> > For the interactive part, would returning
> > 
> > (list (list colw (intern rsel) (intern scope)))
> > 
> > pass
> > 
> > ((72 tabtrail global)) ; list with single element being a list
> > 
> > or
> > 
> > (72 tabtrail global) ; list of three entries
> > 
> > to actm-seqr?
> 
> 
> The answer is in message displayed when you do `M-x poalatuk' and act
> appropriately on the prompts, isn't it?

With only  

   (list colw rsel scope)

rather than 

   (list (list colw rsel scope))

I get 

   Debugger entered--Lisp error: (wrong-number-of-arguments ((t) (actm-seqr) "Visualisation of spaces including tabs and trailin..."

poalatuk(72 "tabtrail" "local")

> > > > Have also been looking at the possibility of using
> > > > 
> > > > (list (list colw (intern rsel) (intern scope)))
> > > > 
> > > > Or would this be considered replication? Because the call
> > > > to intern would happen later anyway.
> > > 
> > > Then it would cause the error you reported in your OP.
> > 
> > (list (list colw (intern rsel) (intern scope)))
> > 
> > The above will be for the interactive part, so that the string values
> > would be changed immediately to symbols.
> > 
> > And since I now fixed the problem by checking with stringp so intern gets
> > called when calling the function programatically with strings.
> 
> 
> Ok.
> 
> Steve Berman



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

end of thread, other threads:[~2024-11-29 22:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 17:34 Passing a list of symbols to function argument Heime via Users list for the GNU Emacs text editor
2024-11-29 19:54 ` Stephen Berman
2024-11-29 20:15   ` Heime via Users list for the GNU Emacs text editor
2024-11-29 20:41     ` Stephen Berman
2024-11-29 21:16       ` Heime via Users list for the GNU Emacs text editor
2024-11-29 21:29         ` Stephen Berman
2024-11-29 21:41           ` Heime via Users list for the GNU Emacs text editor
2024-11-29 21:52             ` Stephen Berman
2024-11-29 22:45               ` Heime via Users list for the GNU Emacs text editor

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.