From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alexis Roda Newsgroups: gmane.emacs.help Subject: Re: Optional Arguments Date: Mon, 7 Dec 2020 20:51:06 +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="19933"; mail-complaints-to="usenet@ciao.gmane.io" 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:53:45 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 1kmMZt-00054q-Gi for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 20:53:45 +0100 Original-Received: from localhost ([::1]:45734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmMZr-00074U-IS for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 14:53:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmMXk-0006TG-QB for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 14:51:32 -0500 Original-Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:46798) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmMXb-0002o6-9x for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 14:51:27 -0500 Original-Received: by mail-wr1-x430.google.com with SMTP id l9so4823052wrt.13 for ; Mon, 07 Dec 2020 11:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AS6iPKTJ1UOVxJpRNwqDuQs6M2wl7CSShrPpfMMGrfY=; b=Sc2HOywr6R6gwdTUFGOgfjWos7J/qjzsU32lIiBj/tnISpq+jqBzcBilOZgGTcbR8N tEAn7z2DNdYfApdUamwrMlJZXW2NH5AkkST5ydva7+ZnQ7cxWj02dG2E9Wp2vTu1Evl1 5CK7n2l2dSTKKUw2OGjnM/zrhYcK7OJS2w1z1VfgWSZapbaE/tHkjNTy3bLQQSF9P5ug 2f/HqkdgBg2doPTf4eP3ldYkZKeI9Tnr2EMeywhXuBPt6tTcFGzd5xBTW2/CzIodPfBu yHYEULf0c55/Q+LDS5rEHfr/81QXBPegWjlgyw4B3vcsSHETgKs/h3Eh0O9AabZkEjEH xqyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AS6iPKTJ1UOVxJpRNwqDuQs6M2wl7CSShrPpfMMGrfY=; b=RHCVtZHJGfw/ZaephlaEbZidXiH00O5bzY6tFp5E6zOHlu/cU0rGNFCQP0aTCyaBDK g7HW9+sEG92eiBoFL6QonzCwfc1Xtf2LJyv4aKpqGs6piWY0xGsDrS65Hd5c8lt9b90M 6jZySTaEbaRPMz+xPB8rAt2zQx83c9bc3iVWy9S02zuTJPfBgOAUDTZ2d/KnNC4qqXy7 GmUJA5zmy5ZTM/67aBWHyxyT7sSL9bqBeJ5JNN2XQGZagCOYL6WMjc3bsWA9i1yxe4PZ Qb38oO2pbofxEOTfmQO2WcgKXYgfwCDcd1epINCEBcnXgh3LGGhj0NoVFRlT3FG9s175 kXVg== X-Gm-Message-State: AOAM530p9NDjWiAbKoDbR3mWQ8zdifUBDq4nhTqGAzrTfkhmA8szzBS/ ek+pIxsKSitXGPxremOrzCdTAR3F7dUB5HfzjC8= X-Google-Smtp-Source: ABdhPJxXmMZwRgExV3c06yvp3lO9FZNRjriVGbb/R9Cqlq0UClAjQGjSSwbND6z0a8cNYfsVvfYwSDLd3YpkyQbV2b8= X-Received: by 2002:a5d:498a:: with SMTP id r10mr3043410wrq.238.1607370678333; Mon, 07 Dec 2020 11:51:18 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alexis.roda.villalonga@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:126166 Archived-At: https://www.gnu.org/software/emacs/manual/html_node/eintr/Parts-of-let-Expr= ession.html According to that, your let expression defines a variable called 'ma' initialized with the value given by 'mb', which is not defined at that point. Try with: (defun word-markers () (let ((ma nil) (mb nil)) (skip-chars-backward "[:alpha:]") (setq ma (point)) (skip-chars-forward "[:alpha:]") (setq mb (point)) (cons ma mb))) or (defun word-markers () (let (ma mb) (skip-chars-backward "[:alpha:]") (setq ma (point)) (skip-chars-forward "[:alpha:]") (setq mb (point)) (cons ma mb))) In the second example 'ma' and 'mb' are initialized implicitly with nil. Also variables '$mu' and '$mv' aren't defined. Missatge de l'adre=C3=A7a del dia dl., 7 de des. 2020= a les 19:18: > 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. > > > > Sent: Monday, December 07, 2020 at 4:38 PM > > From: tomas@tuxteam.de > > To: pietru@caramail.com > > Cc: "Help Gnu Emacs" > > Subject: Re: Optional Arguments > > > > On Mon, Dec 07, 2020 at 03:24:36PM +0100, pietru@caramail.com wrote: > > > > [...] > > > > > > =3D> "ma: 15 mb: 26" > > > > > > Hmmm. Variables local to function. > > > > Yes. "Local" meaning here either dynamical extent (called functions > > "see" the variables up the call chain, think Unix shells) or > > lexical extent (code contexts "see" the variables of enclosing > > code contexts (think C or Java or...), depending on whether you > > chose lexical binding [1]. > > > > [...] > > > > > > ...would you expect it to change the number 15 to whatever the word= 's > > > > beginning position is? You would mess up maths with that :) > > > > > > Yes, it would mess up. > > > > G=C3=B6del's nothing against that :-D > > > > Cheers > > > > [1] Cf. Chapter "Lexical Binding" in the Elisp manual, or here > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Lexical-Binding= .html > > > > - t > > > >