* Lisp indentation. @ 2005-03-10 18:26 Lute Kamstra 2005-03-10 19:43 ` Stefan Monnier 0 siblings, 1 reply; 10+ messages in thread From: Lute Kamstra @ 2005-03-10 18:26 UTC (permalink / raw) I was trying to give (with-no-warnings ...) the same indentation as (progn ...). Now I have a few question: In about 25% of the cases the lisp-indent-hook property is used to specify the desired indentation and in the remaining 75% of the cases, the lisp-indent-function property is used. Is the second preferred? (The docsting of the function lisp-indent-function suggest this.) Should occurrences of lisp-indent-hook be renamed to lisp-indent-function? In most cases the indentation property is put on the symbol at the place the symbol is defined. Symbols that are defined in C get their indentation property in lisp/emacs-lisp/lisp-mode.el. There are however a few symbols that are defined in lisp elsewhere that get their lisp-indent-function property set in lisp-mode.el. For example save-selected-window, save-match-data, and with-current-buffer. Is there some policy wrt the place where the indentation property should be set? Lute. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-10 18:26 Lisp indentation Lute Kamstra @ 2005-03-10 19:43 ` Stefan Monnier 2005-03-11 1:29 ` Lute Kamstra 2005-03-13 13:23 ` Lute Kamstra 0 siblings, 2 replies; 10+ messages in thread From: Stefan Monnier @ 2005-03-10 19:43 UTC (permalink / raw) Cc: emacs-devel > In about 25% of the cases the lisp-indent-hook property is used to > specify the desired indentation and in the remaining 75% of the cases, > the lisp-indent-function property is used. Is the second preferred? > (The docsting of the function lisp-indent-function suggest this.) > Should occurrences of lisp-indent-hook be renamed to > lisp-indent-function? Yes, although there is no urgency. > In most cases the indentation property is put on the symbol at the > place the symbol is defined. Symbols that are defined in C get their > indentation property in lisp/emacs-lisp/lisp-mode.el. There are > however a few symbols that are defined in lisp elsewhere that get > their lisp-indent-function property set in lisp-mode.el. For example > save-selected-window, save-match-data, and with-current-buffer. Is > there some policy wrt the place where the indentation property should > be set? I'd say they should be set in the `declare' part of the definition of the macro. See the definition of `when' or `unless' for examples. Unless it's common to edit code that uses the macro while the macro itself is not loaded, in which case it might be worthwhile to put the `put' in some other file like lisp-mode.el. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-10 19:43 ` Stefan Monnier @ 2005-03-11 1:29 ` Lute Kamstra 2005-03-12 17:40 ` Lute Kamstra 2005-03-13 13:23 ` Lute Kamstra 1 sibling, 1 reply; 10+ messages in thread From: Lute Kamstra @ 2005-03-11 1:29 UTC (permalink / raw) Cc: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >> In about 25% of the cases the lisp-indent-hook property is used to >> specify the desired indentation and in the remaining 75% of the >> cases, the lisp-indent-function property is used. Is the second >> preferred? (The docsting of the function lisp-indent-function >> suggest this.) Should occurrences of lisp-indent-hook be renamed >> to lisp-indent-function? > > Yes, although there is no urgency. > >> In most cases the indentation property is put on the symbol at the >> place the symbol is defined. Symbols that are defined in C get >> their indentation property in lisp/emacs-lisp/lisp-mode.el. There >> are however a few symbols that are defined in lisp elsewhere that >> get their lisp-indent-function property set in lisp-mode.el. For >> example save-selected-window, save-match-data, and >> with-current-buffer. Is there some policy wrt the place where the >> indentation property should be set? > > I'd say they should be set in the `declare' part of the definition > of the macro. Ah, yes; I forgot about the declare thingy of macros. > See the definition of `when' or `unless' for examples. Unless it's > common to edit code that uses the macro while the macro itself is > not loaded, in which case it might be worthwhile to put the `put' in > some other file like lisp-mode.el. Thanks for clarifying. So this would be a good patch then. Lute. Index: lisp/ChangeLog =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.7083 diff -c -r1.7083 ChangeLog *** lisp/ChangeLog 10 Mar 2005 21:43:16 -0000 1.7083 --- lisp/ChangeLog 11 Mar 2005 01:17:36 -0000 *************** *** 1,3 **** --- 1,9 ---- + 2005-03-11 Lute Kamstra <lute@gnu.org> + + * emacs-lisp/byte-run.el: Replace lisp-indent-hook with + lisp-indent-function throughout. + (with-no-warnings): Set lisp-indent-function property. + 2005-03-10 Stefan Monnier <monnier@iro.umontreal.ca> * help.el (describe-mode): Properly handle non-trivial lighters. Index: lisp/emacs-lisp/byte-run.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/byte-run.el,v retrieving revision 1.6 diff -c -r1.6 byte-run.el *** lisp/emacs-lisp/byte-run.el 7 May 2004 00:58:54 -0000 1.6 --- lisp/emacs-lisp/byte-run.el 11 Mar 2005 01:17:37 -0000 *************** *** 1,6 **** ;;; byte-run.el --- byte-compiler support for inlining ! ;; Copyright (C) 1992, 2004 Free Software Foundation, Inc. ;; Author: Jamie Zawinski <jwz@lucid.com> ;; Hallvard Furuseth <hbf@ulrik.uio.no> --- 1,6 ---- ;;; byte-run.el --- byte-compiler support for inlining ! ;; Copyright (C) 1992, 2004, 2005 Free Software Foundation, Inc. ;; Author: Jamie Zawinski <jwz@lucid.com> ;; Hallvard Furuseth <hbf@ulrik.uio.no> *************** *** 34,40 **** ;; Redefined in byte-optimize.el. ;; This is not documented--it's not clear that we should promote it. (fset 'inline 'progn) ! (put 'inline 'lisp-indent-hook 0) ;;; Interface to inline functions. --- 34,40 ---- ;; Redefined in byte-optimize.el. ;; This is not documented--it's not clear that we should promote it. (fset 'inline 'progn) ! (put 'inline 'lisp-indent-function 0) ;;; Interface to inline functions. *************** *** 105,111 **** (put variable 'byte-obsolete-variable (cons new when)) variable) ! (put 'dont-compile 'lisp-indent-hook 0) (defmacro dont-compile (&rest body) "Like `progn', but the body always runs interpreted (not compiled). If you think you need this, you're probably making a mistake somewhere." --- 105,111 ---- (put variable 'byte-obsolete-variable (cons new when)) variable) ! (put 'dont-compile 'lisp-indent-function 0) (defmacro dont-compile (&rest body) "Like `progn', but the body always runs interpreted (not compiled). If you think you need this, you're probably making a mistake somewhere." *************** *** 118,124 **** ;;; definition in the file overrides the magic definitions on the ;;; byte-compile-macro-environment. ! (put 'eval-when-compile 'lisp-indent-hook 0) (defmacro eval-when-compile (&rest body) "Like `progn', but evaluates the body at compile time. The result of the body appears to the compiler as a quoted constant." --- 118,124 ---- ;;; definition in the file overrides the magic definitions on the ;;; byte-compile-macro-environment. ! (put 'eval-when-compile 'lisp-indent-function 0) (defmacro eval-when-compile (&rest body) "Like `progn', but evaluates the body at compile time. The result of the body appears to the compiler as a quoted constant." *************** *** 127,139 **** ;; (list 'quote (eval (cons 'progn body))) (cons 'progn body)) ! (put 'eval-and-compile 'lisp-indent-hook 0) (defmacro eval-and-compile (&rest body) "Like `progn', but evaluates the body at compile time and at load time." (declare (debug t)) ;; Remember, it's magic. (cons 'progn body)) (defun with-no-warnings (&rest body) "Like `progn', but prevents compiler warnings in the body." ;; The implementation for the interpreter is basically trivial. --- 127,140 ---- ;; (list 'quote (eval (cons 'progn body))) (cons 'progn body)) ! (put 'eval-and-compile 'lisp-indent-function 0) (defmacro eval-and-compile (&rest body) "Like `progn', but evaluates the body at compile time and at load time." (declare (debug t)) ;; Remember, it's magic. (cons 'progn body)) + (put 'with-no-warnings 'lisp-indent-function 0) (defun with-no-warnings (&rest body) "Like `progn', but prevents compiler warnings in the body." ;; The implementation for the interpreter is basically trivial. *************** *** 147,153 **** ;;; There is hardly any reason to change these parameters, anyway. ;;; --rms. ! ;; (put 'byte-compiler-options 'lisp-indent-hook 0) ;; (defmacro byte-compiler-options (&rest args) ;; "Set some compilation-parameters for this file. This will affect only the ;; file in which it appears; this does nothing when evaluated, and when loaded --- 148,154 ---- ;;; There is hardly any reason to change these parameters, anyway. ;;; --rms. ! ;; (put 'byte-compiler-options 'lisp-indent-function 0) ;; (defmacro byte-compiler-options (&rest args) ;; "Set some compilation-parameters for this file. This will affect only the ;; file in which it appears; this does nothing when evaluated, and when loaded ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-11 1:29 ` Lute Kamstra @ 2005-03-12 17:40 ` Lute Kamstra 0 siblings, 0 replies; 10+ messages in thread From: Lute Kamstra @ 2005-03-12 17:40 UTC (permalink / raw) Cc: emacs-devel Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> writes: [...] > So this would be a good patch then. Ai, what was I smoking? The defmacros should get a (declare (indent 0)) of course. Lute. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-10 19:43 ` Stefan Monnier 2005-03-11 1:29 ` Lute Kamstra @ 2005-03-13 13:23 ` Lute Kamstra 2005-03-13 13:51 ` Stefan Monnier 2005-03-14 3:00 ` Richard Stallman 1 sibling, 2 replies; 10+ messages in thread From: Lute Kamstra @ 2005-03-13 13:23 UTC (permalink / raw) Cc: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: [...] > I'd say they should be set in the `declare' part of the definition > of the macro. See the definition of `when' or `unless' for > examples. Unless it's common to edit code that uses the macro while > the macro itself is not loaded, in which case it might be worthwhile > to put the `put' in some other file like lisp-mode.el. Actually, there is a problem with using declare to specify indentation. Some macro's like `eval-when-compile' are defined upon startup, because loadup.el loads the file in which they are defined. If (put ... 'lisp-indent-function ...) is used to specify indentation, then that is executed during startup as well. However, if (declare (indent ...)) is used to specify indentation, then the macro is defined during startup, but its lisp-indent-property will not be set. [I guess, this is why there is a (put 'when 'lisp-indent-function 1) in lisp-mode.el, even though the definition of when in subr.el uses (declare (indent 1)).] (declare (debug ...)) has the same problem wrt the edebug-form-spec property. This should probably be fixed somehow, or else documented. Lute. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-13 13:23 ` Lute Kamstra @ 2005-03-13 13:51 ` Stefan Monnier 2005-03-13 16:29 ` Lute Kamstra 2005-03-14 3:00 ` Richard Stallman 1 sibling, 1 reply; 10+ messages in thread From: Stefan Monnier @ 2005-03-13 13:51 UTC (permalink / raw) Cc: emacs-devel > However, if (declare (indent ...)) is used to specify indentation, then > the macro is defined during startup, but its lisp-indent-property will not > be set. Huh? That's not the behavior I see. > [I guess, this is why there is a (put 'when 'lisp-indent-function 1) > in lisp-mode.el, even though the definition of when in subr.el uses > (declare (indent 1)).] No, it's just that I haven't installed this part of my local changes yet. > This should probably be fixed somehow, or else documented. It'd be a blatant bug that needs urgent fixing. Can you show us some recipe that demonstrates the problem? Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-13 13:51 ` Stefan Monnier @ 2005-03-13 16:29 ` Lute Kamstra 2005-03-14 12:58 ` Stefan Monnier 0 siblings, 1 reply; 10+ messages in thread From: Lute Kamstra @ 2005-03-13 16:29 UTC (permalink / raw) Cc: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >> However, if (declare (indent ...)) is used to specify indentation, >> then the macro is defined during startup, but its >> lisp-indent-property will not be set. > > Huh? That's not the behavior I see. [...] >> This should probably be fixed somehow, or else documented. > > It'd be a blatant bug that needs urgent fixing. Can you show us > some recipe that demonstrates the problem? I tried it with eval-when-compile in byte-run.el. With current CVS and "emacs -Q", I see: (symbol-plist 'eval-when-compile) => (lisp-indent-function 0) (symbol-function 'eval-when-compile) => (macro . #[(&rest body) "\301\bB\207" [body progn] 2 600648]) (load (symbol-file 'eval-when-compile)) (symbol-plist 'eval-when-compile) => (lisp-indent-function 0 edebug-form-spec t) (symbol-function 'eval-when-compile) => (macro . #[(&rest body) "\301\bB\207" [body progn] 2 ("/soft/careful/emacs/lisp/emacs-lisp/byte-run.elc" . 3048)]) However, when I remove the (put 'eval-when-compile 'lisp-indent-function 0) and use (declare (debug t) (indent 0)) instead, do a make bootstrap, and then use "emacs -Q", I see: (symbol-plist 'eval-when-compile) => nil (symbol-function 'eval-when-compile) => (macro . #[(&rest body) "\301\bB\207" [body progn] 2 600648]) (load (symbol-file 'eval-when-compile)) (symbol-plist 'eval-when-compile) => (edebug-form-spec t lisp-indent-function 0) (symbol-function 'eval-when-compile) => (macro . #[(&rest body) "\301\bB\207" [body progn] 2 ("/soft/careful/emacs/lisp/emacs-lisp/byte-run.elc" . 3010)]) Lute. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-13 16:29 ` Lute Kamstra @ 2005-03-14 12:58 ` Stefan Monnier 2005-03-14 13:55 ` Lute Kamstra 0 siblings, 1 reply; 10+ messages in thread From: Stefan Monnier @ 2005-03-14 12:58 UTC (permalink / raw) Cc: emacs-devel > I tried it with eval-when-compile in byte-run.el. With current CVS Oh, right, the `declare' only works after subr.el has been loaded, so it's ignored if you use it in byte-run.el or in backquote.el. See (setq macro-declaration-function 'macro-declaration-function) in subr.el. Feel free to fix byte-run.el to not use `declare' (with a note explaining why), or to move the `macro-declaration-function' from subr.el to byte-run.el. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-14 12:58 ` Stefan Monnier @ 2005-03-14 13:55 ` Lute Kamstra 0 siblings, 0 replies; 10+ messages in thread From: Lute Kamstra @ 2005-03-14 13:55 UTC (permalink / raw) Cc: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >> I tried it with eval-when-compile in byte-run.el. With current CVS > > Oh, right, the `declare' only works after subr.el has been loaded, > so it's ignored if you use it in byte-run.el or in backquote.el. > > See (setq macro-declaration-function 'macro-declaration-function) in > subr.el. Feel free to fix byte-run.el to not use `declare' (with a > note explaining why), or to move the `macro-declaration-function' > from subr.el to byte-run.el. I see: byte-run.el and backquote.el are loaded before subr.el by loadup.el. I'll move macro-declaration-function to byte-run.el and put in a comment why it should be there. Lute. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Lisp indentation. 2005-03-13 13:23 ` Lute Kamstra 2005-03-13 13:51 ` Stefan Monnier @ 2005-03-14 3:00 ` Richard Stallman 1 sibling, 0 replies; 10+ messages in thread From: Richard Stallman @ 2005-03-14 3:00 UTC (permalink / raw) Cc: monnier, emacs-devel If (put ... 'lisp-indent-function ...) is used to specify indentation, then that is executed during startup as well. However, if (declare (indent ...)) is used to specify indentation, then the macro is defined during startup, but its lisp-indent-property will not be set. There are many special precautions needed for preloaded code. This should probably be fixed somehow, or else documented. It is worth fixing if someone finds a very simple and safe fix. Otherwise it would be worth adding a very brief note in the manual. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-03-14 13:55 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-03-10 18:26 Lisp indentation Lute Kamstra 2005-03-10 19:43 ` Stefan Monnier 2005-03-11 1:29 ` Lute Kamstra 2005-03-12 17:40 ` Lute Kamstra 2005-03-13 13:23 ` Lute Kamstra 2005-03-13 13:51 ` Stefan Monnier 2005-03-13 16:29 ` Lute Kamstra 2005-03-14 12:58 ` Stefan Monnier 2005-03-14 13:55 ` Lute Kamstra 2005-03-14 3:00 ` Richard Stallman
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.