[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optional Arguments
From: |
pietru |
Subject: |
Re: Optional Arguments |
Date: |
Mon, 7 Dec 2020 22:21:22 +0100 |
> Sent: Monday, December 07, 2020 at 9:52 PM
> From: "Arthur Miller" <arthur.miller@live.com>
> To: "Michael Heerdegen" <michael_heerdegen@web.de>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Optional Arguments
>
> Michael Heerdegen <michael_heerdegen@web.de> writes:
>
> > pietru@caramail.com writes:
> >
> >> Am getting an error with the following.
> >>
> >> (defun word-markers ()
> >> (let ((ma mb)) <--
I see it now, the parenthesis was assigning to ma other than nil.
Thank you so very much.
> > You bind `ma' to the value of `mb'. That's not what you want.
> Exactly; this is what I had in my scratch when I tested: I just didn't
> copy everything in previous answer:
>
> (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 ma (car bounds))
> (setq mb (cdr bounds))))
> (message "Bounds: %s" (pp bounds))
> (message "Region: [%s %s]" ma mb)
> (message "Region-string: [%s]" (buffer-substring-no-properties ma mb))))
>
> (test)
>
> Tou should drop one parenthesis around ma and mb in your let
> expression. That will declare two variables and initialize them to nil both.
>
>
- Re: Optional Arguments, (continued)
- Re: Optional Arguments, tomas, 2020/12/07
- Re: Optional Arguments, Anders Dalskov, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, tomas, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Arthur Miller, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Michael Heerdegen, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Arthur Miller, 2020/12/07
- Re: Optional Arguments,
pietru <=
- Re: Optional Arguments, Alexis Roda, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, tomas, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Arthur Miller, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Stefan Monnier, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Christopher Dimech, 2020/12/07