From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: pietru@caramail.com Newsgroups: gmane.emacs.help Subject: Re: Optional Arguments Date: Mon, 7 Dec 2020 20:42:59 +0100 Message-ID: References: <20201207130630.GA10719@tuxteam.de> <20201207153847.GB15617@tuxteam.de> 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="30916"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Arthur Miller Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 07 20:47:12 2020 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 1kmMTX-0007v1-92 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 20:47:11 +0100 Original-Received: from localhost ([::1]:42410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmMTV-00054q-1P for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 14:47:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmMPf-00054Q-9A for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 14:43:11 -0500 Original-Received: from mout.gmx.net ([212.227.17.22]:41585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmMPd-0000A6-Ec for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 14:43:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607370179; bh=ZQu8h3hAr2QOAsuNZcoW30a5nePeVW2HH9W51cczE+Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=CCJjcuSRdIGzyX8JT8N8AO6osifDVZfhf+7RJaqjQDnATC817KZvQ4y5mCNpb/YBK He0fWkQlFP1eTNomwpz1chJAFvjP7ZyMq3TlOCtORCTrn6Z1IbZp0gEi2hLBvYEvAp QFlgdmN5/XBqlhcxrfle7IZnkfJnKjJ+r9ZE3mrI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs11.server.lan [172.19.170.179]) (via HTTP); Mon, 7 Dec 2020 20:42:59 +0100 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:wdYwrxji3HoxLnh7szsnKG2IQBEco2o/iQ38C0ik4VSKYErBMSNT/6RukVc5IA+rq//yE GZKC9kuo4GnVmwfZgYnzQwfFaMEoHpD++JaSopliUIIUksy87SJkX/uJLmxwV8Jlpjmq76HsGxOB Pf9HnZEdIsGvCiUccp/9DNfm6voiCr6LyAE55M0hi3C49WjVe6MlItfFQ+xnrsYmsHlXIs/MUPw3 Fn+XPobic/t+kjtW94mdQcgA2PksrE+Lnk5aOe0uFPJlNd/BSPyHPuM6791NrqjgQntabkAbT4JP G4= X-UI-Out-Filterresults: notjunk:1;V03:K0:3ccPJhaVstI=:bbDupHxwEQyYxwlf1tlJWw jjVkGxm5CZ1zrR3tIPIgiih9gX5WIkUMRf3WPnUlZjOVLW2hOEKAA58ap8x497fr5J7zg52Ai HqkUDPVwHAAAlGC/9DHfN6KtYbVQQfJg8NG7Erugw+26QyAdA28ehVMMM0n3Dt6mSpboP8dCR 5WeDKWeGnFzXdfwvgwMrYcO5Y1vHAsyewIO0246O26ruurIXcVOwUSIf7TXnr4VEkJm4GeQxB Kcob8UapAwmTKmvbfl2lmpRBDGhsL6pf6Bo784c4PKTJok4rMJYbCCFuqJmC1qwafUjVAq4/x fVmKO/EfVVsE/c3il9PBfJWp1h8LZPYxkdQ8odHuXhePq3etD+Mo4Y3Blv7iFkrzzeq+1z8p1 T0IOQmpWBbure6yAT9ofDZ16Zwp9znBFQjx9ZMMBV0H9ncQ/ElANe+nY+UFoOaSc+4ffkoX3D MUg3zuRpOEYa5uzk9jTQa2jMGtrWryT47FvCOMtP11fxZ5Ch0idfD2PB8AF55cL/oJEO0y6qA hJ729Zc1eKVCWaxfQ4bMGQ2wAM5/zTr4q+BnjrfW51Nn5ROoOF5q415gXIa76bEr0zOVkufM5 gOdApsaJ00UIU= Received-SPF: pass client-ip=212.227.17.22; envelope-from=pietru@caramail.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 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" Xref: news.gmane.io gmane.emacs.help:126165 Archived-At: Am getting an error with the following. (defun word-markers () (let ((ma mb)) ;;(message "s: %s" (cdr (bounds-of-thing-at-point 'word))) (skip-chars-backward "[:alpha:]") (setq ma (point)) (skip-chars-forward "[:alpha:]") (setq mb (point)) (cons ma mb) )) Debugger entered--Lisp error: (void-variable mb) (let ((ma mb)) (skip-chars-backward "[:alpha:]") (setq ma (point)) (skip= -chars-forward "[:alpha:]") (setq mb (point)) (cons ma mb)) word-markers() > Sent: Monday, December 07, 2020 at 8:01 PM > From: "Arthur Miller" > To: pietru@caramail.com > Cc: tomas@tuxteam.de, "Help Gnu Emacs" > Subject: Re: Optional Arguments > > pietru@caramail.com writes: > > > I'm having a go at returning the two values from a function > > > > (defun word-markers () > > (let ((ma mb)) > > (skip-chars-backward "[:alpha:]") > > (setq ma (point)) > > (skip-chars-forward "[:alpha:]") > > (setq mb (point)) > > (cons ma mb) )) > > > > (defun test () > > (interactive) > > > > (let ((deactivate-mark nil) bounds $ma $mb) > > (if (use-region-p) > > (setq $ma (region-beginning) $mb (region-end)) > > (save-excursion > > (setq bounds (word-markers)) > > (setq $mu (car bounds)) > > (setq $mv (car bounds)) )) > > > > (message "Bounds: %s" $bounds) > > (message "Region: [%s, %s]" $ma $mb) )) > > > > But something's not right. > > You have probably made a typo when you are setq-ing 'mu' and 'mv' > > > (setq $mu (car bounds)) <-- introducing new variable in global scope: = $mu > > (setq $mv (car bounds)) <-- same here: $mv > > > (message "Region: [%s, %s]" $ma $mb) <-- potentially nil vars $ma and = $mb > > You probably want somthing like this: > > (defun test () > (interactive) > (let ((deactivate-mark nil) > bounds ma mb) > (if (use-region-p) > (setq ma (region-beginning) mb (region-end)) > (save-excursion > (setq bounds (word-markers)) > (setq ma (car bounds)) > (setq mb (cdr bounds)))) > (message "Bounds: %s" (pp bounds)) > (message "Region: [%s %s]" ma mb) > (message "Region string: [%s]" (buffer-substring ma mb)))) >