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 16:06:13 +0100 Message-ID: References: <20201207130630.GA10719@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="39426"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 07 16:10:40 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 1kmI9v-000A9k-VS for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 16:10:39 +0100 Original-Received: from localhost ([::1]:43240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmI9u-00057P-Qz for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 10:10:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmI5n-000512-HM for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 10:06:23 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:32853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmI5l-0005sJ-GI for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 10:06:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607353574; bh=lzeKTrg6B0ZL+0rDy+3pFYoG2K0OkSBaqUDORhDdazg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=hpaFm8HQz1YmDmv8hkcU5S1hU51P0qgekJV/4UFd27dBj7j6oG8UxgdrDWhTixBH4 lRKDoqB/eKkaPWI08ikgDE5lFbv63WA84JJv5NOGWDsNZdZ8b6TOK/8Zt7E/+RFGBo pO7EDmw64kuxzLh8mL9gGgv4+vcdrG1KfsYjs7XE= 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 16:06:13 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <20201207130630.GA10719@tuxteam.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:181v/TXY0f6vDuTnIZ7r+OfrZGFoOKkmyWjn62f4rFLhgm0ymZTfLJUJp4H0YLJFctnGy GJhDo3c8AePx63TrvIhNZb0pvtfaRbvvPc21Ewca4GfFEc1mTyR4OZwZcTq+cHWOKBCQk5YIbcbL 2DCWyEhN+7rkCJMyCrBS3TJnn3LuDbtqwq3VSmK3u/ddpmBXT2B/v75Kszj+FaOP9uk08Ma139Vp ytwDisLhXEdaOB7iPFEG/v3u93VzKWv2Z07+JLh/grsVG6pGCdQw+wq75f2IzeUgkfdoRdLJtcWE 3M= X-UI-Out-Filterresults: notjunk:1;V03:K0:BW7kp0GluV4=:BgKmrLLBrV8pzZg/XgIaPJ SSp+R95MfPKe9eeojI8CiHYyLTNPN0qnqOd/jjRdvpWDwStSQBv1A/Juo8WmEFLN+hsIZ/kpz w/TAGyypSwJkbbebepNFmEx/fd0QOWhoRgl7xfliB9ztpy4JIGwjsYilyaIl/FXTJNXxED6zC 2nldkxim+6uq6czQlaSE+UJB4QwFErPsAVT5NmtOxa4lKKrksfaqNQKKljxuIdFNS1MEkT/+C 7rVNv4jzkWyYkqBTj73X2mjZCZMwq7zFZ1eGVEdSpZDh7mIv/G6xcillDcvN6df529UGn2xto i3A4WiTylE28MIaOv4PrWTgYgo763A/6QiWkrq6dBvTNvy2b9gwObxqZg027FRigXwTjIIZYz 863NToUMS55wqUA0aUpE5c23lJJlJWjSTwZ+meafMBFfLiamdmbGvkWyIH0FI9HGPbqDmnVnE fVZvxUZtRrA2TuikLQ3KWWWj9Kl+fo1c3u9VJvnt4EgTlyGRpvM+VqDirPKpRflbE3YmLzxI6 DJK6z8VWlQ4aWuDS7xsr1C+hdUVy4lF7J+WeKLNfTehljefJOf19LsR1BK0ie3Cw02Kjh+8GY 8KjKkv4MjlB9Y= Received-SPF: pass client-ip=212.227.15.19; 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:126154 Archived-At: > Sent: Monday, December 07, 2020 at 2:06 PM > From: tomas@tuxteam.de > To: pietru@caramail.com > Cc: "Help Gnu Emacs" > Subject: Re: Optional Arguments > > 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 calle= d > > 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) > > =3D> "ma: 5 mb: 6" > > (message "ma: %d mb: %d" ma mb) > > =3D> "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 :) How can one get computed values from a function then? > Cheers > - t >