From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.help Subject: Re: Optional Arguments Date: Mon, 07 Dec 2020 20:01:59 +0100 Message-ID: References: <20201207130630.GA10719@tuxteam.de> <20201207153847.GB15617@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32294"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Help Gnu Emacs To: pietru@caramail.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 07 20:03:27 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 1kmLnC-0008Hx-81 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 20:03:26 +0100 Original-Received: from localhost ([::1]:48378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmLnB-0001Gc-80 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 14:03:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmLlz-0001G3-KZ for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 14:02:12 -0500 Original-Received: from mail-oln040092073084.outbound.protection.outlook.com ([40.92.73.84]:23306 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmLlr-0004DS-4N for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 14:02:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QGfySfu2qD7wb/walyqRdIbL7AhKAPLEpTwIPxg4iW+0yhytxbZf8/c4CGUf5DSbFRQMwl8GwOrcJfzlvVFPFOiOXHvg4saUEJ51GKQBI0+xfQjgoGeVpPb/ox3142/KB1mIjbVmChVbprCJLKCPIaqHm875V4t8EDpJM/2sHO+64k9F8zbrExb57J2rddqToFH8/awLw09qcnIZtWs2UTVCnNFQJO6ZiHBnA1PPtuEut8xSzi5a7JUSavmDQtKqWyUYzU8Sb5sKx+xa9OjDCmQy1uloFoA0lNTkWJ9LcOZwO6xJVRkDN6ufuN7yXDSz/+zZapuArJFMDU3VIldBBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/7vsv0vEt1VTfeGFILFC74ic8v5z6Uj1aHj4HhzghY0=; b=YxO4jiE4r0Vf52ImqL2WPSnuHtmS/OPa7m82fSGvgDrvIL3mwHbHYKNE2HkDyJ9QNhz8IF3ihP/OAgXSUYlJXaLln1bA/LiqFt4zyVn8p0cHdZqQOLRjCpDy4/j3VaKPjGLnn5ijBwTA2TUjpYLxeW09WTZDz5pcFyolDP8GngYIW18MVXXc9Q7bgTwKkNUcqFPpt+V9jV2q9jz8q49gjaJ8Bx12RnnqoQ/YIOc354uM5B4GPvLo1X4+D3b1Idaqcri8foPxDZnTrVWZvAaiKf/G0ofvzVWNbDKfRdKj7E1Gn6kKSFHflk01mXTbg2oOSjLK5PXQgGJC8mK4g0184Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/7vsv0vEt1VTfeGFILFC74ic8v5z6Uj1aHj4HhzghY0=; b=DJ7Bfq6RYVSkrQhMLaRd1ZGGAkHsGcwJpEHlIO5AtoYE3cAfCEPDeAFZgRtBfmEXIUUgAVh+shZ9Kn7Gq/5jFH2O3qHPFhX7+0Sv7pwox7b6aSvTZBZp4X/qqTfliSVfENLTqc1mo3vLsNj+xx3bHnqkH9UNW3OW03DJUlmTQXhRfZtgzT9wy3D2BjPaLNPT8MqExfD08ktKxB3o4FIu2iPeGc8bgIyo1KdQZTeLw4SHivcrJ8hzVqbslImHoiPg8TM7nG6TXKYuxczQjAw0ZBfBg9Cj7omcyOQ9fwm/UGEWZoyxxyubt2QHUz0geyIZ75/NERRRCPl/Anp6XG/z2w== Original-Received: from HE1EUR04FT061.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::50) by HE1EUR04HT163.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 19:02:00 +0000 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com (2a01:111:e400:7e0d::48) by HE1EUR04FT061.mail.protection.outlook.com (2a01:111:e400:7e0d::306) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Mon, 7 Dec 2020 19:02:00 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BD7C85DD9341E643CDABBF70B8C60975D019D6802EDE0C9C34D5CB174297B199; UpperCasedChecksum:0594A51D5E7F76BB76423B708CE66C5F7B01A34EF969E2AAA112E5115C7F6340; SizeAsReceived:7889; Count:46 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993]) by AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993%7]) with mapi id 15.20.3632.018; Mon, 7 Dec 2020 19:02:00 +0000 In-Reply-To: (pietru@caramail.com's message of "Mon, 7 Dec 2020 19:13:06 +0100") X-TMN: [sCR1t/GAztiUgz3V+adxr3LYJCjAioaY] X-ClientProxiedBy: AM6P193CA0062.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::39) To AM0PR06MB6577.eurprd06.prod.outlook.com (2603:10a6:208:19a::23) X-Microsoft-Original-Message-ID: <874kkxsamw.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM6P193CA0062.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Mon, 7 Dec 2020 19:01:59 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 309bb18d-67b9-4af4-201b-08d89ae2936f X-MS-TrafficTypeDiagnostic: HE1EUR04HT163: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3etwrh6hAZfkBCDxTs8uYe0Kbt6vloe7NihZaMGGfD5giDgMoQl2t4r7gygNZAncL847u7HKZBIJJkeFBIsfEUT7x4YAXGkkbTQhLjPeTmZKVGVAiaNcYbElZRTv4OEXMY/V2PxiD8H6DYi3xVtnHbeUnQHx7XrUzz4ccbLVgn9koz0fyQh6jisgtJGIDnXQiwQtCBb/swXEfyVwyGSuAg== X-MS-Exchange-AntiSpam-MessageData: mphiKe0fVCrWsPHxFBl/ybF8MUq5pq99nU2ennD0/gkGyviKRYTzbAs6L97W7rn5n6Us5xTbkdQhXsGtES1d3JxA2p+bwGB4sYHRP32jJO6i6C/3hOFLBGnbb5kDzKHdrhKOLEx9MTQGChDbLgPRTw== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 309bb18d-67b9-4af4-201b-08d89ae2936f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 19:02:00.2871 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT061.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT163 Received-SPF: pass client-ip=40.92.73.84; envelope-from=arthur.miller@live.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.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:126162 Archived-At: 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))))