help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to tame compiler?


From: Emanuel Berg
Subject: Re: How to tame compiler?
Date: Sat, 01 May 2021 00:06:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Jorge P. de Morais Neto wrote:

>>> Is there a way to avoid these warnings?
>>
>> Yes: don't abuse `eval` ;-)

Stefan Monnier who wrote that last part, or anyone else for
that matter, what is the rule of thumb when to and when not to
use `eval'?

Maybe something for the docstring?

I have used eval 2 times in all my Elisp. If we apply the rule
of thumb, what will that tell me, is that abuse or not?

For the record I don't get any warnings from either.

(defun wrap-search-again (&optional new-options)
  "Repeat the previous `wrap-search' with NEW-OPTIONS.
NEW-OPTIONS can be supplied with \\[universal-argument].
Otherwise options from the previous search are used."
  (interactive "p")
  (let ((cmd (cl-find-if (lambda (c)
                           (and (eq (car c) #'wrap-search)
                                (not (string= (cl-caddr c) "")) ))
                         command-history) ))
    (if cmd
        (if (= new-options 1)
            (eval cmd)
          (let*((search-str (cl-caddr cmd))
                (final-cmd  (list #'wrap-search new-options search-str)) )
            (setq command-history (cons final-cmd command-history))
            (apply final-cmd) ))
      (message "no previous search") )))

(defun do-repeat-complex-command ()
  (interactive)
  (eval (car command-history) ))

full source:

  https://dataswamp.org/~incal/emacs-init/ide/lisp-incal.el
  https://dataswamp.org/~incal/emacs-init/wrap-search.el

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]