| 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. |
|---|
| | 485 | See `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. |
|---|
| 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))) |
|---|