From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Anders Dalskov" Newsgroups: gmane.emacs.help Subject: Re: Optional Arguments Date: Mon, 07 Dec 2020 14:35:51 +0100 Message-ID: References: <20201207130630.GA10719@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="13596"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.3.0-622-g4a97c0b-fm-20201115.001-g4a97c0b3 Cc: Help Gnu Emacs To: tomas@tuxteam.de, pietru@caramail.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 07 14:37:43 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 1kmGhy-0003Qx-Af for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 14:37:42 +0100 Original-Received: from localhost ([::1]:58154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmGhx-00027L-C1 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 08:37:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmGgk-00020r-2O for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 08:36:26 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmGgY-0007xS-Kd for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 08:36:25 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C90A65C0062; Mon, 7 Dec 2020 08:36:11 -0500 (EST) Original-Received: from imap1 ([10.202.2.51]) by compute3.internal (MEProxy); Mon, 07 Dec 2020 08:36:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=1il6T8iHYTXyzwIGyqrUe4Qvw5fDnCr /FwUK5lALfYY=; b=uORZfjwJhmRcdk4nrHt0rAC9sY+Qco66Qc4hhcqockegIMD ZR7nG72zm8BxN6EWeW+xSzY74C4usjOSPzHvqtAcBadi7X2FC9pw9rCetm1IhwMh NkvqoiQAsifIVMEO4pf5WluUcESd6lhdRm04lozRdlMVPAlZGjOA5lskD7bGQ/yg e4U8Wmf3K7Wfchv8u9Pmp3y11VnVuK5JuHyZ9U6XrBO6UX+JYzuxxWHKxm6l7FRB agL/wNPBkWdgtWZFYwelTLBBcptekVuIF1VGjEVu13ddhKxkBxA0n+jvEtbrR6KQ YnroPaHw/CUAOLGJF1QJpmBFKUuLlDrR3ALMJ8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=1il6T8 iHYTXyzwIGyqrUe4Qvw5fDnCr/FwUK5lALfYY=; b=ZOW32HD/+LkUyOUq7ly7DA H52nOHbIN0OEz4ZahP5QfvQ7Vb5A3lt/ikoKu6fXR+NmX7XjOe11yRJHdRurJe/C /Hcll/s5NuTzmJkVBjmj9aDy5ther4hB13gHO7W29czE1hNWUj4yVIVq8/VuouBp zGz9+cKFlzlGjjK0Yy5PQBgc689LY2Du3OO0QU/BIMgpMwhUAxAsv0vsIXjrrDDg w+X+gEwTyZVxgvhE3NLBH0kcLJREQxZGhBFm+440IWKIo0fbMiAaenYTJQzEaqJA vr8KkYxZF10Jxt8pq06oVTvDyHqmruzcG4kYyNF4dYsFYjvmgEwyHun2ZiTWAO9w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejgedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdetnhgu vghrshcuffgrlhhskhhovhdfuceorghnuggvrhhsphhkugesfhgrshhtmhgrihhlrdgtoh hmqeenucggtffrrghtthgvrhhnpefhgeduheeiffekhefgieeiudetgfdtieeghfdtudfg hefhhfejkeekvdejfeffheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrnhguvghrshhpkhgusehfrghsthhmrghilhdrtghomh X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 53487C200A5; Mon, 7 Dec 2020 08:36:11 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <20201207130630.GA10719@tuxteam.de> Received-SPF: pass client-ip=66.111.4.28; envelope-from=anderspkd@fastmail.com; helo=out4-smtp.messagingengine.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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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:126151 Archived-At: Doesn't `(bounds-of-thing-at-point 'word)` accomplish what you want? On Mon, Dec 7, 2020, at 14:06, tomas@tuxteam.de wrote: > On Mon, Dec 07, 2020 at 01:37:34PM +0100, pietru@caramail.com wrote: > > > > > > > Sent: Monday, December 07, 2020 at 9:16 AM > > > From: "Alexis Roda" > > > To: pietru@caramail.com > > > Cc: "Help Gnu Emacs" > > > Subject: Re: Optional Arguments > > > > > > Hi, > > > > > > Not sure what your question is. > > > > It is bit confusing. > > > > I want to use typh-word-markers to compute ma and mb so I can use the > > two values in another function. Had put (interactive) in my effort to > > test it, but created problems as you say. The function would be called > > when cursor is on a word, so that I get the word "beg" and "end". > > > > (defun typh-word-markers (ma mb) > > [...] > > As Alexis already said, the parameters in your function aren't probably > doing what you think they do. Consider: > > (setq ma 15) > (setq mb 26) > > (defun foo (ma mb) > (setq ma 5) > (setq mb 6) > (message "ma: %d mb: %d" ma mb)) > > (foo ma mb) > > => "ma: 5 mb: 6" > > (message "ma: %d mb: %d" ma mb) > > => "ma: 15 mb: 26" > > I suspect you are passing the parameters to get their values > "outside" the function. I can only guess that, because you don't > show any context (take this into account to help others help > you :) > > But this won't work, because the (setq ...) whithin the function > doesn't "see" the variables outside, but creates variables inside, > initialized to whatever /values/ you pass to the function at call > time. > > In other words: what would you expect your function `typh-word-markers' > do do if you call it like so: > > (typh-word-markers 15 16) > > ...would you expect it to change the number 15 to whatever the word's > beginning position is? You would mess up maths with that :) > > Cheers > - t > > Attachments: > * signature.asc -- Anders