aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-06-21 22:51:00 +0000
committerDan Nicolaescu2007-06-21 22:51:00 +0000
commite96e1531630222502e59383a0cc1ebc3e7be031a (patch)
treed409deaa5111f29687a9484876728f0d87244b6a
parent515f0896149b0c6376168993677c339386743582 (diff)
downloademacs-e96e1531630222502e59383a0cc1ebc3e7be031a.tar.gz
emacs-e96e1531630222502e59383a0cc1ebc3e7be031a.zip
vera-mode.el (vera-mode): Fix `commend-end-skip' setting.
(vera-font-lock-match-item): Fix doc string. (vera-in-comment-p): Remove unused function. (vera-skip-forward-literal,vera-skip-backward-literal): Improve code, use `syntax-ppss'. (vera-forward-syntactic-ws): Fix argument order. (vera-prepare-search): Use `with-syntax-table'. (vera-indent-line): Fix doc string. (vera-electric-tab): Fix doc string. (vera-expand-abbrev): Define alias instead of using `fset'. (vera-comment-uncomment-region): Use `comment-start-skip'.
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/progmodes/vera-mode.el107
2 files changed, 58 insertions, 63 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5dd9aaa036e..148374e0652 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12007-06-21 Reto Zimmermann <reto@gnu.org>
2
3 * vera-mode.el (vera-mode): Fix `commend-end-skip' setting.
4 (vera-font-lock-match-item): Fix doc string.
5 (vera-in-comment-p): Remove unused function.
6 (vera-skip-forward-literal,vera-skip-backward-literal): Improve code,
7 use `syntax-ppss'.
8 (vera-forward-syntactic-ws): Fix argument order.
9 (vera-prepare-search): Use `with-syntax-table'.
10 (vera-indent-line): Fix doc string.
11 (vera-electric-tab): Fix doc string.
12 (vera-expand-abbrev): Define alias instead of using `fset'.
13 (vera-comment-uncomment-region): Use `comment-start-skip'.
14
12007-06-21 Carsten Dominik <dominik@science.uva.nl> 152007-06-21 Carsten Dominik <dominik@science.uva.nl>
2 16
3 * textmodes/org.el (org-export-with-footnotes): New option. 17 * textmodes/org.el (org-export-with-footnotes): New option.
diff --git a/lisp/progmodes/vera-mode.el b/lisp/progmodes/vera-mode.el
index 60debef2f04..124aaceb1f9 100644
--- a/lisp/progmodes/vera-mode.el
+++ b/lisp/progmodes/vera-mode.el
@@ -5,14 +5,14 @@
5 5
6;; Author: Reto Zimmermann <reto@gnu.org> 6;; Author: Reto Zimmermann <reto@gnu.org>
7;; Maintainer: Reto Zimmermann <reto@gnu.org> 7;; Maintainer: Reto Zimmermann <reto@gnu.org>
8;; Version: 2.26 8;; Version: 2.28
9;; Keywords: languages vera 9;; Keywords: languages vera
10;; WWW: http://www.iis.ee.ethz.ch/~zimmi/emacs/vera-mode.html 10;; WWW: http://www.iis.ee.ethz.ch/~zimmi/emacs/vera-mode.html
11 11
12(defconst vera-version "2.18" 12(defconst vera-version "2.18"
13 "Vera Mode version number.") 13 "Vera Mode version number.")
14 14
15(defconst vera-time-stamp "2007-06-11" 15(defconst vera-time-stamp "2007-06-21"
16 "Vera Mode time stamp for last update.") 16 "Vera Mode time stamp for last update.")
17 17
18;; This file is part of GNU Emacs. 18;; This file is part of GNU Emacs.
@@ -88,6 +88,7 @@
88(defgroup vera nil 88(defgroup vera nil
89 "Customizations for Vera Mode." 89 "Customizations for Vera Mode."
90 :prefix "vera-" 90 :prefix "vera-"
91 :version "22.2"
91 :group 'languages) 92 :group 'languages)
92 93
93(defcustom vera-basic-offset 2 94(defcustom vera-basic-offset 2
@@ -105,7 +106,7 @@ are treated as single words otherwise."
105 106
106(defcustom vera-intelligent-tab t 107(defcustom vera-intelligent-tab t
107 "*Non-nil means `TAB' does indentation, word completion and tab insertion. 108 "*Non-nil means `TAB' does indentation, word completion and tab insertion.
108That is, if preceeding character is part of a word then complete word, 109That is, if preceding character is part of a word then complete word,
109else if not at beginning of line then insert tab, 110else if not at beginning of line then insert tab,
110else if last command was a `TAB' or `RET' then dedent one step, 111else if last command was a `TAB' or `RET' then dedent one step,
111else indent current line. 112else indent current line.
@@ -314,7 +315,7 @@ Key bindings:
314 (set (make-local-variable 'comment-end) "") 315 (set (make-local-variable 'comment-end) "")
315 (set (make-local-variable 'comment-column) 40) 316 (set (make-local-variable 'comment-column) 40)
316 (set (make-local-variable 'comment-start-skip) "/\\*+ *\\|//+ *") 317 (set (make-local-variable 'comment-start-skip) "/\\*+ *\\|//+ *")
317 (set (make-local-variable 'comment-end-skip) " *\\*+/\\| *//+") 318 (set (make-local-variable 'comment-end-skip) " *\\*+/\\| *\n")
318 (set (make-local-variable 'comment-indent-function) 'c-comment-indent) 319 (set (make-local-variable 'comment-indent-function) 'c-comment-indent)
319 (set (make-local-variable 'paragraph-start) "^$") 320 (set (make-local-variable 'paragraph-start) "^$")
320 (set (make-local-variable 'paragraph-separate) paragraph-start) 321 (set (make-local-variable 'paragraph-separate) paragraph-start)
@@ -605,8 +606,8 @@ Key bindings:
605 (copy-face 'font-lock-preprocessor-face 'font-lock-builtin-face)) 606 (copy-face 'font-lock-preprocessor-face 'font-lock-builtin-face))
606 607
607(defun vera-font-lock-match-item (limit) 608(defun vera-font-lock-match-item (limit)
608 "Match, and move over, any declaration item after point. Adapted from 609 "Match, and move over, any declaration item after point.
609`font-lock-match-c-style-declaration-item-and-skip-to-next'." 610Adapted from `font-lock-match-c-style-declaration-item-and-skip-to-next'."
610 (condition-case nil 611 (condition-case nil
611 (save-restriction 612 (save-restriction
612 (narrow-to-region (point-min) limit) 613 (narrow-to-region (point-min) limit)
@@ -686,7 +687,6 @@ Key bindings:
686 (t (:italic t :bold t))) 687 (t (:italic t :bold t)))
687 "Font lock mode face used to highlight @ definitions." 688 "Font lock mode face used to highlight @ definitions."
688 :group 'font-lock-highlighting-faces) 689 :group 'font-lock-highlighting-faces)
689(put 'vera-font-lock-number-face 'face-alias 'vera-font-lock-number)
690 690
691(defface vera-font-lock-function 691(defface vera-font-lock-function
692 '((((class color) (background light)) (:foreground "DarkCyan")) 692 '((((class color) (background light)) (:foreground "DarkCyan"))
@@ -694,7 +694,6 @@ Key bindings:
694 (t (:italic t :bold t))) 694 (t (:italic t :bold t)))
695 "Font lock mode face used to highlight predefined functions and tasks." 695 "Font lock mode face used to highlight predefined functions and tasks."
696 :group 'font-lock-highlighting-faces) 696 :group 'font-lock-highlighting-faces)
697(put 'vera-font-lock-function-face 'face-alias 'vera-font-lock-function)
698 697
699(defface vera-font-lock-interface 698(defface vera-font-lock-interface
700 '((((class color) (background light)) (:foreground "Grey40")) 699 '((((class color) (background light)) (:foreground "Grey40"))
@@ -702,13 +701,8 @@ Key bindings:
702 (t (:italic t :bold t))) 701 (t (:italic t :bold t)))
703 "Font lock mode face used to highlight interface names." 702 "Font lock mode face used to highlight interface names."
704 :group 'font-lock-highlighting-faces) 703 :group 'font-lock-highlighting-faces)
705(put 'vera-font-lock-interface-face 'face-alias 'vera-font-lock-interface)
706
707(defun vera-fontify-buffer ()
708 "Fontify buffer."
709 (interactive)
710 (font-lock-fontify-buffer))
711 704
705(defalias 'vera-fontify-buffer 'font-lock-fontify-buffer)
712 706
713;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 707;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
714;;; Indentation 708;;; Indentation
@@ -788,7 +782,7 @@ the offset is simply returned."
788;; help functions 782;; help functions
789 783
790(defsubst vera-point (position) 784(defsubst vera-point (position)
791 "Returns the value of point at certain commonly referenced POSITIONs. 785 "Return the value of point at certain commonly referenced POSITIONs.
792POSITION can be one of the following symbols: 786POSITION can be one of the following symbols:
793 bol -- beginning of line 787 bol -- beginning of line
794 eol -- end of line 788 eol -- end of line
@@ -819,29 +813,34 @@ This function does not modify point or mark."
819 ((nth 4 state) 'comment) 813 ((nth 4 state) 'comment)
820 (t nil))))) 814 (t nil)))))
821 815
822(defun vera-in-comment-p ()
823 "Determine if point is in a Vera comment."
824 (save-excursion
825 (re-search-backward "\\(/\\*\\)\\|\\(\\*/\\)" nil t)
826 (match-string 1)))
827
828(defun vera-skip-forward-literal () 816(defun vera-skip-forward-literal ()
829 "Skip forward literal and return t if within one." 817 "Skip forward literal and return t if within one."
830 (let ((state (save-excursion (parse-partial-sexp (point-min) (point))))) 818 (let ((state (save-excursion
831 (cond 819 (if (fboundp 'syntax-ppss)
832 ((nth 3 state) (search-forward "\"") t) ; inside string 820 (syntax-ppss)
833 ((nth 7 state) (forward-line 1) t) ; inside // comment 821 (parse-partial-sexp (point-min) (point))))))
834 ((nth 4 state) (search-forward "*/") t) ; inside /* */ comment 822 (when (nth 8 state)
835 (t nil)))) 823 ;; Inside a string or comment.
824 (goto-char (nth 8 state))
825 (if (nth 3 state)
826 ;; A string.
827 (condition-case nil (forward-sexp 1)
828 ;; Can't find end of string: it extends til end of buffer.
829 (error (goto-char (point-max))))
830 ;; A comment.
831 (forward-comment 1))
832 t)))
836 833
837(defun vera-skip-backward-literal () 834(defun vera-skip-backward-literal ()
838 "Skip backward literal and return t if within one." 835 "Skip backward literal and return t if within one."
839 (let ((state (save-excursion (parse-partial-sexp (point-min) (point))))) 836 (let ((state (save-excursion
840 (cond 837 (if (fboundp 'syntax-ppss)
841 ((nth 3 state) (search-backward "\"") t) ; inside string 838 (syntax-ppss)
842 ((nth 7 state) (search-backward "//") t) ; inside // comment 839 (parse-partial-sexp (point-min) (point))))))
843 ((nth 4 state) (search-backward "/*") t) ; inside /* */ comment 840 (when (nth 8 state)
844 (t nil)))) 841 ;; Inside a string or comment.
842 (goto-char (nth 8 state))
843 t)))
845 844
846(defsubst vera-re-search-forward (regexp &optional bound noerror) 845(defsubst vera-re-search-forward (regexp &optional bound noerror)
847 "Like `re-search-forward', but skips over matches in literals." 846 "Like `re-search-forward', but skips over matches in literals."
@@ -867,7 +866,7 @@ This function does not modify point or mark."
867 (let* ((lim (or lim (point-max))) 866 (let* ((lim (or lim (point-max)))
868 (here lim) 867 (here lim)
869 (hugenum (point-max))) 868 (hugenum (point-max)))
870 (narrow-to-region lim (point)) 869 (narrow-to-region (point) lim)
871 (while (/= here (point)) 870 (while (/= here (point))
872 (setq here (point)) 871 (setq here (point))
873 (forward-comment hugenum) 872 (forward-comment hugenum)
@@ -891,25 +890,8 @@ This function does not modify point or mark."
891 (beginning-of-line))))))) 890 (beginning-of-line)))))))
892 891
893(defmacro vera-prepare-search (&rest body) 892(defmacro vera-prepare-search (&rest body)
894 "Switch to syntax table that includes '_', then execute BODY, and finally 893 "Execute BODY with a syntax table that includes '_'."
895restore the old environment. Used for consistent searching." 894 `(with-syntax-table vera-mode-ext-syntax-table ,@body))
896 `(let ((current-syntax-table (syntax-table))
897 result
898 (restore-prog ; program to restore enviroment
899 '(progn
900 ;; restore syntax table
901 (set-syntax-table current-syntax-table))))
902 ;; use extended syntax table
903 (set-syntax-table vera-mode-ext-syntax-table)
904 ;; execute BODY safely
905 (setq result
906 (condition-case info
907 (progn ,@body)
908 (error (eval restore-prog) ; restore environment on error
909 (error (cadr info))))) ; pass error up
910 ;; restore environment
911 (eval restore-prog)
912 result))
913 895
914;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 896;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
915;; comment indentation functions 897;; comment indentation functions
@@ -1197,7 +1179,7 @@ try to increase performance by using this macro."
1197 (goto-char placeholder) 1179 (goto-char placeholder)
1198 (vera-add-syntax 'statement (vera-point 'boi))) 1180 (vera-add-syntax 'statement (vera-point 'boi)))
1199 ;; CASE 9: at the beginning of a substatement? 1181 ;; CASE 9: at the beginning of a substatement?
1200 ;; is this line preceeded by a substatement opening statement? 1182 ;; is this line preceded by a substatement opening statement?
1201 ((save-excursion (vera-backward-syntactic-ws nil t) 1183 ((save-excursion (vera-backward-syntactic-ws nil t)
1202 (when (= (preceding-char) ?\)) (backward-sexp)) 1184 (when (= (preceding-char) ?\)) (backward-sexp))
1203 (backward-word 1) 1185 (backward-word 1)
@@ -1222,9 +1204,8 @@ try to increase performance by using this macro."
1222;; indentation functions 1204;; indentation functions
1223 1205
1224(defun vera-indent-line () 1206(defun vera-indent-line ()
1225 "Indent the current line as Vera code. Optional SYNTAX is the 1207 "Indent the current line as Vera code.
1226syntactic information for the current line. Returns the amount of 1208Return the amount of indentation change (in columns)."
1227indentation change (in columns)."
1228 (interactive) 1209 (interactive)
1229 (vera-prepare-search 1210 (vera-prepare-search
1230 (let* ((syntax (vera-guess-basic-syntax)) 1211 (let* ((syntax (vera-guess-basic-syntax))
@@ -1273,8 +1254,9 @@ Calls `indent-region' for whole buffer."
1273;; electrifications 1254;; electrifications
1274 1255
1275(defun vera-electric-tab (&optional prefix-arg) 1256(defun vera-electric-tab (&optional prefix-arg)
1276 "If preceeding character is part of a word or a paren then hippie-expand, 1257 "Do what I mean (indent, expand, tab, change indent, etc..).
1277else if right of non whitespace on line then tab-to-tab-stop, 1258If preceding character is part of a word or a paren then `hippie-expand',
1259else if right of non whitespace on line then `tab-to-tab-stop',
1278else if last command was a tab or return then dedent one step or if a comment 1260else if last command was a tab or return then dedent one step or if a comment
1279toggle between normal indent and inline comment indent, 1261toggle between normal indent and inline comment indent,
1280else indent `correctly'. 1262else indent `correctly'.
@@ -1423,9 +1405,8 @@ If `vera-intelligent-tab' is nil, always indent line."
1423 t)) 1405 t))
1424 1406
1425;; function for expanding abbrevs and dabbrevs 1407;; function for expanding abbrevs and dabbrevs
1426(defun vera-expand-abbrev (arg)) 1408(defalias 'vera-expand-abbrev
1427(fset 'vera-expand-abbrev (make-hippie-expand-function 1409 (make-hippie-expand-function '(try-expand-dabbrev
1428 '(try-expand-dabbrev
1429 try-expand-dabbrev-all-buffers 1410 try-expand-dabbrev-all-buffers
1430 vera-try-expand-abbrev))) 1411 vera-try-expand-abbrev)))
1431 1412
@@ -1436,7 +1417,7 @@ If `vera-intelligent-tab' is nil, always indent line."
1436 "Comment region if not commented, uncomment region if already commented." 1417 "Comment region if not commented, uncomment region if already commented."
1437 (interactive "r\nP") 1418 (interactive "r\nP")
1438 (goto-char beg) 1419 (goto-char beg)
1439 (if (looking-at (regexp-quote comment-start)) 1420 (if (looking-at comment-start-skip)
1440 (comment-region beg end '(4)) 1421 (comment-region beg end '(4))
1441 (comment-region beg end))) 1422 (comment-region beg end)))
1442 1423