Show
Ignore:
Timestamp:
09/18/06 20:48:14 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/textmodes/conf-mode.el

    r4037 r4166  
    7676    (define-key map "\C-c\C-w" 'conf-windows-mode) 
    7777    (define-key map "\C-c\C-j" 'conf-javaprop-mode) 
    78     (define-key map "\C-c\C-s" 'conf-space-mode
    79     (define-key map "\C-c " 'conf-space-mode
     78    (define-key map "\C-c\C-s" 'conf-space-keywords
     79    (define-key map "\C-c " 'conf-space-keywords
    8080    (define-key map "\C-c\C-c" 'conf-colon-mode) 
    8181    (define-key map "\C-c:" 'conf-colon-mode) 
     
    169169    ("/dictionary\\.lst\\'" . "DICT\\|HYPH\\|THES") 
    170170    ("/tuxracer/options" . "set")) 
    171   "File name based settings for `conf-space-keywords'.") 
     171  "File-name-based settings for the variable `conf-space-keywords'.") 
    172172 
    173173(defvar conf-space-keywords nil 
     
    189189                '(2 'font-lock-variable-name-face)) 
    190190          '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face))) 
    191   "Keywords to hilight in Conf Space mode.") 
     191  "Keywords to highlight in Conf Space mode.") 
    192192 
    193193(defvar conf-colon-font-lock-keywords 
     
    447447  "Conf Mode starter for space separated conf files. 
    448448\"Assignments\" are with ` '.  Keywords before the parameters are 
    449 recognized according to `conf-space-keywords'.  Interactively 
     449recognized according to the variable `conf-space-keywords'.  Interactively 
    450450with a prefix ARG of `0' no keywords will be recognized.  With 
    451451any other prefix arg you will be prompted for a regexp to match 
     
    466466add /dev/mixer          desktop" 
    467467  (conf-mode-initialize "#" 'conf-space-font-lock-keywords) 
    468   (set (make-local-variable 'conf-assignment-sign) 
    469        nil) 
    470   ;; This doesn't seem right, but the next two depend on conf-space-keywords 
    471   ;; being set, while after-change-major-mode-hook might set up imenu, needing 
    472   ;; the following result: 
    473   (hack-local-variables-prop-line) 
    474   (hack-local-variables) 
    475   (cond (current-prefix-arg 
    476          (set (make-local-variable 'conf-space-keywords) 
    477               (if (> (prefix-numeric-value current-prefix-arg) 0) 
    478                   (read-string "Regexp to match keywords: ")))) 
    479         (conf-space-keywords) 
    480         (buffer-file-name 
    481          (set (make-local-variable 'conf-space-keywords) 
    482               (assoc-default buffer-file-name conf-space-keywords-alist 
    483                              'string-match)))) 
    484   (set (make-local-variable 'conf-assignment-regexp) 
    485        (if conf-space-keywords 
    486            (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)") 
    487          ".+?\\([ \t]+\\|$\\)")) 
     468  (make-local-variable 'conf-assignment-sign) 
     469  (setq conf-assignment-sign nil) 
     470  (make-local-variable 'conf-space-keywords) 
     471  (cond (buffer-file-name 
     472         ;; By setting conf-space-keywords directly,  
     473         ;; we let a value in the local variables list take precedence. 
     474         (make-local-variable 'conf-space-keywords) 
     475         (setq conf-space-keywords 
     476               (assoc-default buffer-file-name conf-space-keywords-alist 
     477                              'string-match)))) 
     478  (conf-space-mode-internal) 
     479  ;; In case the local variables list specifies conf-space-keywords, 
     480  ;; recompute other things from that afterward. 
     481  (add-hook 'hack-local-variables-hook 'conf-space-mode-internal nil t)) 
     482 
     483(defun conf-space-keywords (keywords) 
     484  "Enter Conf Space mode using regexp KEYWORDS to match the keywords. 
     485See `conf-space-mode'." 
     486  (interactive "sConf Space keyword regexp: ") 
     487  (delay-mode-hooks 
     488    (conf-space-mode)) 
     489  (if (string-equal keyword "") 
     490      (setq keywords nil)) 
     491  (setq conf-space-keywords keywords) 
     492  (conf-space-mode-internal) 
     493  (run-mode-hooks)) 
     494 
     495(defun conf-space-mode-internal () 
     496  (make-local-variable 'conf-assignment-regexp) 
     497  (setq conf-assignment-regexp 
     498        (if conf-space-keywords 
     499            (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)") 
     500          ".+?\\([ \t]+\\|$\\)")) 
     501  ;; If Font Lock is already enabled, reenable it with new 
     502  ;; conf-assignment-regexp. 
     503  (when (and font-lock-mode 
     504             (boundp 'font-lock-keywords)) ;see `normal-mode' 
     505    (font-lock-add-keywords nil nil) 
     506    (font-lock-mode 1)) 
     507  ;; Copy so that we don't destroy shared structure. 
     508  (setq imenu-generic-expression (copy-sequence imenu-generic-expression)) 
     509  ;; Get rid of any existing Parameters element. 
    488510  (setq imenu-generic-expression 
    489         `(,@(cdr imenu-generic-expression) 
    490           ("Parameters" 
    491            ,(if conf-space-keywords 
    492                 (concat "^[ \t]*\\(?:" conf-space-keywords 
    493                         "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)") 
    494               "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)") 
    495            1)))) 
     511        (delq (assoc "Parameters" imenu-generic-expression) 
     512              imenu-generic-expression)) 
     513  ;; Add a new one based on conf-space-keywords. 
     514  (setq imenu-generic-expression 
     515        (cons `("Parameters" 
     516                ,(if conf-space-keywords 
     517                     (concat "^[ \t]*\\(?:" conf-space-keywords 
     518                             "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)") 
     519                   "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)") 
     520                1)       
     521              imenu-generic-expression))) 
    496522 
    497523;;;###autoload