all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Why is defun not executed during load-file?
@ 2021-05-30  9:02 Jean Louis
  2021-05-30 13:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-05-30 19:44 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 15+ messages in thread
From: Jean Louis @ 2021-05-30  9:02 UTC (permalink / raw)
  To: Help GNU Emacs

I have this in the hyperscope.el and upon load-file the last function
is not executed, it does not generate the functions. But if I evaluate
it specifically, it generates functions.

Is there any reason for that?

(defun hyperscope-generate-the-add-function-by-hyperdocument-type (type-name id function-name)
  (eval `(defun ,(intern (symbol-name function-name)) ()
	   ,(format "Add new `%s' hyperdocument to Hyperscope." type-name)
	   (interactive)
	   (let* ((parent (hyperscope-select-set))
		  (prompt ,(format "New `%s' hyperdocument name: " type-name))
		  (name (read-from-minibuffer prompt)))
	     (hlink-add-generic name "" ,id parent nil)))))

(defun hyperscope-generate-add-functions-by-hyperdocument-types ()
  (let ((types (hyperscope-hyperdocument-types)))
    (while types
      (let* ((type (pop types))
	     (id (nth 0 type))
	     (type (nth 1 type))
	     (type-name type)
	     (type (downcase (string-replace " " "-" type)))
	     (function-name (intern (format "hyperscope-add-new-%s-hyperdocument" type))))
	(hyperscope-generate-the-add-function-by-hyperdocument-type type-name id function-name)))))

(hyperscope-generate-add-functions-by-hyperdocument-types)



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Why is defun not executed during load-file?
@ 2021-05-30 22:48 Drew Adams
  2021-05-30 22:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 15+ messages in thread
From: Drew Adams @ 2021-05-30 22:48 UTC (permalink / raw)
  To: Help-Gnu-Emacs (help-gnu-emacs@gnu.org); +Cc: Emanuel Berg

> Macros are much more difficult to debug...

`macroexpand` and `macroexpand-1` are your friends.

Separate that first step, which is just reduction
(aka rewriting / reduction semantics), from the
subsequent step of Lisp-evaluating the sexp that
results from it.

So debug the macro-expansion step, to ensure you
get the sexp you want.  And debug evaluation of
that sexp - separately.



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

end of thread, other threads:[~2021-05-30 23:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-30  9:02 Why is defun not executed during load-file? Jean Louis
2021-05-30 13:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-30 15:36   ` Jean Louis
2021-05-30 16:32     ` Stefan Monnier
2021-05-30 19:56       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 21:46         ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-30 21:55           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 19:44 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 21:56   ` Jean Louis
2021-05-30 22:07     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:39       ` Jean Louis
2021-05-30 23:26         ` Michael Heerdegen
2021-05-30 23:37           ` Jean Louis
  -- strict thread matches above, loose matches on Subject: below --
2021-05-30 22:48 Drew Adams
2021-05-30 22:57 ` Emanuel Berg via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.