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 15:24:36 +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="7127"; 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 15:28:31 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 1kmHV9-0001jQ-KG for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 15:28:31 +0100 Original-Received: from localhost ([::1]:45618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmHV7-0000Xo-Pe for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 09:28:30 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmHRW-0000XR-Sc for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 09:24:46 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:36061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmHRU-0008Kl-Rw for help-gnu-emacs@gnu.org; Mon, 07 Dec 2020 09:24:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607351076; bh=ZI3GOz0q5d7OyJo0JTXL5o6ZjrpdKVYPimYusT6VT4g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=E3WK5p9rDKMEknUDhzPS/dKzoQfq9wiojrUE03YMOLm2nFOixwblln46Pdp/i/oZL wWmRWXdjFnLPtByz8fgGuQIg22k12Dd20p953tX9/9OsBHtnYSvjuu0T0iXOuiM7LF XFZAkSWtvlQ9vz1fy3aEqcfDRC7v2IJnr+PHUwJw= 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 15:24:36 +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:6kEPgXwFyGMG/iMNLyMELyXCJj5PoD+JtGkjGTYfLzyzZfbp3qKp6L9WdKsLGjdCiS/Cz mFoSSDpGThDx+SV41JP9VzVdk9fUodJzKgjp76WKHoTnu2Awt/iT8NAA6SRPyQ+6AlcFYOKC8dHP m6TRbt+Irm+RtxGjj75bWj+kplulSTJCeFPjsaSKpDk71LLEgDSvtlsvPCwHk70sqSaoRNSDLWoi Bo1aoH2WbiVQ8P7g7Hu+udDAdhqYaP6vxoNwMp77aIFwIc20e8ohWPuFMRnbMGPc/sln9MyDlkD9 o8= X-UI-Out-Filterresults: notjunk:1;V03:K0:PvV0jEJ7I9A=:VB4QprIcePkfEzogHf1Ym/ wVmYFaurgbBpWMzqIkooLyxVqdQepDSn+JV/Llpp99oqCkjeYN7XSXzLviqrmjd7nSonftSek WDaUzmhWqi4Sb/iPhFUxyWM/AG7VoH9+U+AR4bVvMP24lZlkQjEDuaLYhKs4WfqOND1poXoI3 FtwFkwFMFYhKLldTPbdaSHzVi1FW6Kg3CTuqtllC0ld66ywvwW8yoiWa9cy2rSNqRHNsHQuSo 4//KnwB/iYATHfVop2qyF8icxvipjHzQKi7p9A7Kta8d9+Ffhgfp8SIyEgHATNSh7PdB4+OAX BFd3eyTdEI7VyV+cGvw2EY24It/yKpU0Spr04cVVIOJ8B+1IrRaSCPvuzj+M7T5BPi54j6Klz +NkZu9eUe0+mdc0ZTrSsq0ZZFIA3+xEdUWRwriOxCL6rIKtUAgE9XDYi5P5BKsKkfApFhFMGU c2DOnL3Rs5YpjUjMA9uaJ7zjuXofrvb3PCxuBgHSSERmoxr8IGUPFYy7hCRGQIV71afCVGMSM KA0062yVBtu5WaNES+lD5LojQ/fBdwt+uNlKvxTjdw0XVd5tHn0JxXiWecTDCiczbfHjZR4hb G9leYKDsPTy0M= Received-SPF: pass client-ip=212.227.15.18; 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:126152 Archived-At: > Sent: Monday, December 07, 2020 at 2:06 PM > From: tomas@tuxteam.de > To: pietru@caramail.com > Cc: "Alexis Roda" , "Help Gnu Emacs" <= help-gnu-emacs@gnu.org> > 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" Hmmm. Variables local to function. > 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 :) Correct > 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 :) Yes, it would mess up. > Cheers > - t >