* 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
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 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.