changeset 94326:c419e1e2f8ee

(f90-mode-syntax-table): Don't set ` as word syntax. (f90-mode-abbrev-table): Use the new :regexp feature. Merge defvar and mapc into define-abbrev-table. (f90-imenu-type-matcher): Remove unused `l'. (f90-imenu-generic-expression): Remove unused `not-ib'. (f90-prepare-abbrev-list-buffer): Use with-current-buffer. (f90-change-keywords): Use restore-buffer-modified-p.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 24 Apr 2008 15:06:27 +0000
parents 693b7934455a
children ff97f6b52868
files lisp/ChangeLog lisp/progmodes/f90.el
diffstat 2 files changed, 86 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Apr 24 06:06:53 2008 +0000
+++ b/lisp/ChangeLog	Thu Apr 24 15:06:27 2008 +0000
@@ -1,3 +1,13 @@
+2008-04-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/f90.el (f90-mode-syntax-table): Don't set ` as word syntax.
+	(f90-mode-abbrev-table): Use the new :regexp feature.
+	Merge defvar and mapc into define-abbrev-table.
+	(f90-imenu-type-matcher): Remove unused `l'.
+	(f90-imenu-generic-expression): Remove unused `not-ib'.
+	(f90-prepare-abbrev-list-buffer): Use with-current-buffer.
+	(f90-change-keywords): Use restore-buffer-modified-p.
+
 2008-04-24  Glenn Morris  <rgm@gnu.org>
 
 	* net/goto-addr.el (goto-address-prog-mode):
@@ -20,8 +30,8 @@
 
 2008-04-24  Tom Tromey  <tromey@redhat.com>
 
-	* emacs-lisp/easy-mmode.el (easy-mmode-define-keymap): Document
-	keywords.  Add :suppress.
+	* emacs-lisp/easy-mmode.el (easy-mmode-define-keymap):
+	Document keywords.  Add :suppress.
 	* pcvs-defs.el (cvs-mode-map): Use :suppress.
 
 	* net/goto-addr.el (goto-address-unfontify): New function.
--- a/lisp/progmodes/f90.el	Thu Apr 24 06:06:53 2008 +0000
+++ b/lisp/progmodes/f90.el	Thu Apr 24 15:06:27 2008 +0000
@@ -623,10 +623,13 @@
   (let ((table (make-syntax-table)))
     (modify-syntax-entry ?\! "<"  table) ; begin comment
     (modify-syntax-entry ?\n ">"  table) ; end comment
+    ;; FIXME: This goes against the convention: it should be "_".
     (modify-syntax-entry ?_  "w"  table) ; underscore in names
     (modify-syntax-entry ?\' "\"" table) ; string quote
     (modify-syntax-entry ?\" "\"" table) ; string quote
-    (modify-syntax-entry ?\` "w"  table) ; for abbrevs
+    ;; FIXME: We used to set ` to word syntax for the benefit of abbrevs, but
+    ;; we do not need it any more.  Not sure if it should be "_" or "." now.
+    (modify-syntax-entry ?\` "_"  table)
     (modify-syntax-entry ?\r " "  table) ; return is whitespace
     (modify-syntax-entry ?+  "."  table) ; punctuation
     (modify-syntax-entry ?-  "."  table)
@@ -866,7 +869,7 @@
 (defun f90-imenu-type-matcher ()
   "Search backward for the start of a derived type.
 Set subexpression 1 in the match-data to the name of the type."
-  (let (found l)
+  (let (found)
     (while (and (re-search-backward "^[ \t0-9]*type[ \t]*" nil t)
                 (not (setq found
                            (save-excursion
@@ -881,7 +884,8 @@
 (defvar f90-imenu-generic-expression
   (let ((good-char "[^!\"\&\n \t]") (not-e "[^e!\n\"\& \t]")
         (not-n "[^n!\n\"\& \t]") (not-d "[^d!\n\"\& \t]")
-        (not-ib "[^i(!\n\"\& \t]") (not-s "[^s!\n\"\& \t]"))
+        ;; (not-ib "[^i(!\n\"\& \t]") (not-s "[^s!\n\"\& \t]")
+        )
     (list
      '(nil "^[ \t0-9]*program[ \t]+\\(\\sw+\\)" 1)
      '("Modules" "^[ \t0-9]*module[ \t]+\\(\\sw+\\)[ \t]*\\(!\\|$\\)" 1)
@@ -922,81 +926,71 @@
 
 
 ;; Abbrevs have generally two letters, except standard types `c, `i, `r, `t.
-(defvar f90-mode-abbrev-table
-  (progn
-    (define-abbrev-table 'f90-mode-abbrev-table nil)
-    f90-mode-abbrev-table)
-  "Abbrev table for F90 mode.")
-
-;; Not in defvar because user abbrevs may be restored before this file loads.
-(mapc
- (lambda (e)
-   (condition-case nil
-       (define-abbrev f90-mode-abbrev-table (car e) (cdr e) nil :count 0
-         :system t)
-     (wrong-number-of-arguments         ; Emacs 22
-      (define-abbrev f90-mode-abbrev-table (car e) (cdr e) nil 0 t))))
- '(("`al"  . "allocate"     )
-   ("`ab"  . "allocatable"  )
-   ("`ai"  . "abstract interface")
-   ("`as"  . "assignment"   )
-   ("`asy" . "asynchronous" )
-   ("`ba"  . "backspace"    )
-   ("`bd"  . "block data"   )
-   ("`c"   . "character"    )
-   ("`cl"  . "close"        )
-   ("`cm"  . "common"       )
-   ("`cx"  . "complex"      )
-   ("`cn"  . "contains"     )
-   ("`cy"  . "cycle"        )
-   ("`de"  . "deallocate"   )
-   ("`df"  . "define"       )
-   ("`di"  . "dimension"    )
-   ("`dp"  . "double precision")
-   ("`dw"  . "do while"     )
-   ("`el"  . "else"         )
-   ("`eli" . "else if"      )
-   ("`elw" . "elsewhere"    )
-   ("`em"  . "elemental"    )
-   ("`e"   . "enumerator"   )
-   ("`eq"  . "equivalence"  )
-   ("`ex"  . "external"     )
-   ("`ey"  . "entry"        )
-   ("`fl"  . "forall"       )
-   ("`fo"  . "format"       )
-   ("`fu"  . "function"     )
-   ("`fa"  . ".false."      )
-   ("`im"  . "implicit none")
-   ("`in"  . "include"      )
-   ("`i"   . "integer"      )
-   ("`it"  . "intent"       )
-   ("`if"  . "interface"    )
-   ("`lo"  . "logical"      )
-   ("`mo"  . "module"       )
-   ("`na"  . "namelist"     )
-   ("`nu"  . "nullify"      )
-   ("`op"  . "optional"     )
-   ("`pa"  . "parameter"    )
-   ("`po"  . "pointer"      )
-   ("`pr"  . "print"        )
-   ("`pi"  . "private"      )
-   ("`pm"  . "program"      )
-   ("`pr"  . "protected"    )
-   ("`pu"  . "public"       )
-   ("`r"   . "real"         )
-   ("`rc"  . "recursive"    )
-   ("`rt"  . "return"       )
-   ("`rw"  . "rewind"       )
-   ("`se"  . "select"       )
-   ("`sq"  . "sequence"     )
-   ("`su"  . "subroutine"   )
-   ("`ta"  . "target"       )
-   ("`tr"  . ".true."       )
-   ("`t"   . "type"         )
-   ("`vo"  . "volatile"     )
-   ("`wh"  . "where"        )
-   ("`wr"  . "write"        )))
-
+(define-abbrev-table 'f90-mode-abbrev-table
+  (mapcar (lambda (e) (list (car e) (cdr e) nil :system t))
+          '(("`al"  . "allocate"     )
+            ("`ab"  . "allocatable"  )
+            ("`ai"  . "abstract interface")
+            ("`as"  . "assignment"   )
+            ("`asy" . "asynchronous" )
+            ("`ba"  . "backspace"    )
+            ("`bd"  . "block data"   )
+            ("`c"   . "character"    )
+            ("`cl"  . "close"        )
+            ("`cm"  . "common"       )
+            ("`cx"  . "complex"      )
+            ("`cn"  . "contains"     )
+            ("`cy"  . "cycle"        )
+            ("`de"  . "deallocate"   )
+            ("`df"  . "define"       )
+            ("`di"  . "dimension"    )
+            ("`dp"  . "double precision")
+            ("`dw"  . "do while"     )
+            ("`el"  . "else"         )
+            ("`eli" . "else if"      )
+            ("`elw" . "elsewhere"    )
+            ("`em"  . "elemental"    )
+            ("`e"   . "enumerator"   )
+            ("`eq"  . "equivalence"  )
+            ("`ex"  . "external"     )
+            ("`ey"  . "entry"        )
+            ("`fl"  . "forall"       )
+            ("`fo"  . "format"       )
+            ("`fu"  . "function"     )
+            ("`fa"  . ".false."      )
+            ("`im"  . "implicit none")
+            ("`in"  . "include"      )
+            ("`i"   . "integer"      )
+            ("`it"  . "intent"       )
+            ("`if"  . "interface"    )
+            ("`lo"  . "logical"      )
+            ("`mo"  . "module"       )
+            ("`na"  . "namelist"     )
+            ("`nu"  . "nullify"      )
+            ("`op"  . "optional"     )
+            ("`pa"  . "parameter"    )
+            ("`po"  . "pointer"      )
+            ("`pr"  . "print"        )
+            ("`pi"  . "private"      )
+            ("`pm"  . "program"      )
+            ("`pr"  . "protected"    )
+            ("`pu"  . "public"       )
+            ("`r"   . "real"         )
+            ("`rc"  . "recursive"    )
+            ("`rt"  . "return"       )
+            ("`rw"  . "rewind"       )
+            ("`se"  . "select"       )
+            ("`sq"  . "sequence"     )
+            ("`su"  . "subroutine"   )
+            ("`ta"  . "target"       )
+            ("`tr"  . ".true."       )
+            ("`t"   . "type"         )
+            ("`vo"  . "volatile"     )
+            ("`wh"  . "where"        )
+            ("`wr"  . "write"        )))
+  "Abbrev table for F90 mode."
+  ;; Accept ` as the first char of an abbrev.  Also allow _ in abbrevs.
+  :regexp "\\(?:[^[:word:]_`]\\|^\\)\\(`?[[:word:]_]+\\)[^[:word:]_]*")
 
 ;;;###autoload
 (defun f90-mode ()
@@ -2102,8 +2096,7 @@
 
 (defun f90-prepare-abbrev-list-buffer ()
   "Create a buffer listing the F90 mode abbreviations."
-  (save-excursion
-    (set-buffer (get-buffer-create "*Abbrevs*"))
+  (with-current-buffer (get-buffer-create "*Abbrevs*")
     (erase-buffer)
     (insert-abbrev-table-description 'f90-mode-abbrev-table t)
     (goto-char (point-min))
@@ -2172,7 +2165,7 @@
               (funcall change-word -1)
               (or (string= saveword (buffer-substring back-point ref-point))
                   (setq modified t))))
-        (or modified (set-buffer-modified-p nil))))))
+        (or modified (restore-buffer-modified-p nil))))))
 
 
 (defun f90-current-defun ()