From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Passing a list of symbols to function argument Date: Fri, 29 Nov 2024 20:15:04 +0000 Message-ID: References: <87ser97r3k.fsf@gmx.net> Reply-To: Heime Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13441"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 29 21:16:09 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tH7PM-0003Lq-PA for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 29 Nov 2024 21:16:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tH7OZ-0004CN-BK; Fri, 29 Nov 2024 15:15:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH7OV-00049h-Ma for help-gnu-emacs@gnu.org; Fri, 29 Nov 2024 15:15:17 -0500 Original-Received: from mail-43166.protonmail.ch ([185.70.43.166]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH7OT-0005OQ-5c for help-gnu-emacs@gnu.org; Fri, 29 Nov 2024 15:15:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732911310; x=1733170510; bh=OBv3Ks/Y0aNoQrcuUCfW+v426Dv6nwgrD2sMv5cLkUg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=vN571UChbUAylPjJVze9CcHqo5fBkEbIymfGuuIZIilxOF2FGPvcjN9/N89jHC7Ex 8PYcoXfo+tX6zifTH7FNNV++bES8PsBfOTOB86PhvfiJvZkIx4m+aB+OC4sGrlUnfs bW5Nrzffpur+FIehzA4BvT3ZnxZ2OsaO8OItykpdykHrWXjBPE8V6s7GVtxhAOOq2+ oKHziIYMjSRp7km+c0B4CQmq/K12tFssdlpwwtNOkg2V4AXd6E/+QC4AIaJ8VLU9Ji ID/AbBrQylkleRyWtqmjCdBME3/Lkku7oFtzLgg6qPcqPuhQNSRyf/cHhtM2OAMYuC n/BYLzZ5pUA3A== In-Reply-To: <87ser97r3k.fsf@gmx.net> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 4bad23537e78ddbd589876924f315f43b7b9c1be Received-SPF: pass client-ip=185.70.43.166; envelope-from=heimeborgia@protonmail.com; helo=mail-43166.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148445 Archived-At: Sent with Proton Mail secure email. On Saturday, November 30th, 2024 at 7:54 AM, Stephen Berman 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: >=20 > > Why do I get > >=20 > > Wrong type argument: stringp, tabtrail > >=20 > > When using the call > >=20 > > (poalatuk '(72 tabtrail global)) > >=20 > > to the function > >=20 > > (defun poalatuk (actm-seqr) > >=20 > > (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")) ) > >=20 > > ;; Pass a single list as argument > > (list (list colw rsel scope))) ) > >=20 > > ;; ------------------------------------------------------------- > >=20 > > (message "poalatuk: %S" actm-seqr) > >=20 > > (let* ( (colw (nth 0 actm-seqr)) ;; Extract column width. > > (rsel (intern (nth 1 actm-seqr))) ;; Extract mode selector. >=20 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ >=20 > 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. >=20 > Steve Berman I want the function to accept both symbols and strings. intern must then= =20 be applied only when a string is passed. Which undoubtedly needs a conditi= onal 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))=20 (intern (nth 1 actm-seqr)) (nth 1 actm-seqr))) (scope (if (stringp (nth 2 actm-seqr))=20 (intern (nth 2 actm-seqr)) (nth 2 actm-seqr))))