unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* a question about `,' in backquote
@ 2005-04-24 17:49 Masatake YAMATO
  2005-04-24 18:49 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Masatake YAMATO @ 2005-04-24 17:49 UTC (permalink / raw)


I found a following line in the definition of `tags-search':

   (setq tags-loop-scan `(re-search-forward ',regexp nil t)

Could you tell me why "'" is needed before "," ?
Is there any strong reason?

I think it is easier to read next line:

   (setq tags-loop-scan `(re-search-forward ,regexp nil t)


;;;###autoload
(defun tags-search (regexp &optional file-list-form)
  "Search through all files listed in tags table for match for REGEXP.
Stops when a match is found.
To continue searching for next match, use command \\[tags-loop-continue].

See documentation of variable `tags-file-name'."
  (interactive "sTags search (regexp): ")
  (if (and (equal regexp "")
	   (eq (car tags-loop-scan) 're-search-forward)
	   (null tags-loop-operate))
      ;; Continue last tags-search as if by M-,.
      (tags-loop-continue nil)
    (setq tags-loop-scan `(re-search-forward ',regexp nil t)
	  tags-loop-operate nil)
    (tags-loop-continue (or file-list-form t))))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a question about `,' in backquote
  2005-04-24 17:49 a question about `,' in backquote Masatake YAMATO
@ 2005-04-24 18:49 ` Andreas Schwab
  2005-04-25  6:19   ` Masatake YAMATO
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2005-04-24 18:49 UTC (permalink / raw)
  Cc: emacs-devel

Masatake YAMATO <jet@gyve.org> writes:

> I found a following line in the definition of `tags-search':
>
>    (setq tags-loop-scan `(re-search-forward ',regexp nil t)
>
> Could you tell me why "'" is needed before "," ?

Because the form is passed to eval, which evaluates the function arguments
before applying them.  Thus without the quote it would effectively be
doing (eval regexp), which is not what is wanted.  Of course, the only
valid type of this argument is a string which is self-evaluating, but you
don't want to evaluate arbitrary values in the error case.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a question about `,' in backquote
  2005-04-24 18:49 ` Andreas Schwab
@ 2005-04-25  6:19   ` Masatake YAMATO
  0 siblings, 0 replies; 3+ messages in thread
From: Masatake YAMATO @ 2005-04-25  6:19 UTC (permalink / raw)
  Cc: emacs-devel

> [...]  Of course, the only
> valid type of this argument is a string which is self-evaluating, but you
> don't want to evaluate arbitrary values in the error case.

This is the point which I'd like to know.
I have to revise my private elisp library:-(

Thank you.

Masatake YAMATO

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-04-25  6:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-24 17:49 a question about `,' in backquote Masatake YAMATO
2005-04-24 18:49 ` Andreas Schwab
2005-04-25  6:19   ` Masatake YAMATO

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).