* bug#7025: Viper's `viper-deflocalvar' macro doesn't indent properly
@ 2010-09-12 13:46 Vegard Øye
2012-08-05 8:53 ` Chong Yidong
0 siblings, 1 reply; 2+ messages in thread
From: Vegard Øye @ 2010-09-12 13:46 UTC (permalink / raw)
To: 7025
The `viper-deflocalvar' macro in viper-init.el is used for defining
buffer-local variables. However, it doesn't indent properly:
(viper-deflocalvar foo nil
"Docstring")
The following patch adds a `declare' statement to fix the indentation:
(viper-deflocalvar foo nil
"Docstring")
`viper-loop' suffers from the same problem, and is also fixed by the
patch. Furthermore, the patch adds syntax highlighting for
`viper-deflocalvar' and `viper-loop', so that they blend in with
`defvar' and `loop'.
Vegard
--- viper-init.el 2010-09-12 15:22:42.000000000 +0200
+++ viper-init-patched.el 2010-09-12 15:32:35.000000000 +0200
@@ -95,6 +95,10 @@
;;; Macros
(defmacro viper-deflocalvar (var default-value &optional documentation)
+ "Define VAR as a buffer-local variable.
+DEFAULT-VALUE is the default value and DOCUMENTATION is the
+docstring. The variable becomes buffer-local whenever set."
+ (declare (indent defun))
`(progn
(defvar ,var ,default-value
,(format "%s\n\(buffer local\)" documentation))
@@ -102,11 +106,20 @@
;; (viper-loop COUNT BODY) Execute BODY COUNT times.
(defmacro viper-loop (count &rest body)
+ (declare (indent defun))
`(let ((count ,count))
(while (> count 0)
,@body
(setq count (1- count)))))
+(when (fboundp 'font-lock-add-keywords)
+ (font-lock-add-keywords
+ 'emacs-lisp-mode
+ '(("(\\(viper-deflocalvar\\)\\>[ \f\t\n\r\v]*\\(\\sw+\\)?"
+ (1 font-lock-keyword-face)
+ (2 font-lock-variable-name-face nil t))
+ ("(\\(viper-loop\\)\\>" 1 font-lock-keyword-face))))
+
(defmacro viper-buffer-live-p (buf)
`(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#7025: Viper's `viper-deflocalvar' macro doesn't indent properly
2010-09-12 13:46 bug#7025: Viper's `viper-deflocalvar' macro doesn't indent properly Vegard Øye
@ 2012-08-05 8:53 ` Chong Yidong
0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2012-08-05 8:53 UTC (permalink / raw)
To: Vegard Øye; +Cc: 7025
Vegard Øye <vegard_oye@hotmail.com> writes:
> The `viper-deflocalvar' macro in viper-init.el is used for defining
> buffer-local variables. However, it doesn't indent properly:
>
> (viper-deflocalvar foo nil
> "Docstring")
>
> The following patch adds a `declare' statement to fix the indentation
Thanks. I've committed your patch to trunk, except for the font-lock
stuff (we don't generally provide font lock support for such
package-specific compatibility macros).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-05 8:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-12 13:46 bug#7025: Viper's `viper-deflocalvar' macro doesn't indent properly Vegard Øye
2012-08-05 8:53 ` Chong Yidong
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).