From: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: conf-space-mode
Date: Fri, 15 Sep 2006 10:29:40 -0400 [thread overview]
Message-ID: <E1GOEhI-000733-9T@fencepost.gnu.org> (raw)
In-Reply-To: <m27j093b0l.fsf@gaston.none> (message from Wolfgang Jenkner on Tue, 12 Sep 2006 07:32:42 +0200)
I think what you call the `second change' is making C-u C-c SPC work.
Yes.
I meant the part where I remarked that, e.g., `find-file-at-point'
uses `current-prefix-arg'. A call to `conf-space-mode' while
'find-file-at-point' is being executed may still see the same prefix
argument which was passed to `find-file-at-point'.
Now I see the problem you mean.
Now that I think about it, this whole approach is wrong. It is wrong
to look at current-prefix-arg except inside of an interactive spec.
Does this patch make it all work?
*** conf-mode.el 09 Sep 2006 20:28:32 -0400 1.16
--- conf-mode.el 15 Sep 2006 09:30:21 -0400
***************
*** 75,82 ****
(define-key map "\C-c\C-u" 'conf-unix-mode)
(define-key map "\C-c\C-w" 'conf-windows-mode)
(define-key map "\C-c\C-j" 'conf-javaprop-mode)
! (define-key map "\C-c\C-s" 'conf-space-mode)
! (define-key map "\C-c " 'conf-space-mode)
(define-key map "\C-c\C-c" 'conf-colon-mode)
(define-key map "\C-c:" 'conf-colon-mode)
(define-key map "\C-c\C-x" 'conf-xdefaults-mode)
--- 75,82 ----
(define-key map "\C-c\C-u" 'conf-unix-mode)
(define-key map "\C-c\C-w" 'conf-windows-mode)
(define-key map "\C-c\C-j" 'conf-javaprop-mode)
! (define-key map "\C-c\C-s" 'conf-space-keywords)
! (define-key map "\C-c " 'conf-space-keywords)
(define-key map "\C-c\C-c" 'conf-colon-mode)
(define-key map "\C-c:" 'conf-colon-mode)
(define-key map "\C-c\C-x" 'conf-xdefaults-mode)
***************
*** 168,174 ****
("/resmgr\\.conf" . "class\\|add\\|allow\\|deny")
("/dictionary\\.lst\\'" . "DICT\\|HYPH\\|THES")
("/tuxracer/options" . "set"))
! "File name based settings for `conf-space-keywords'.")
(defvar conf-space-keywords nil
"Regexps for functions that may come before a space assignment.
--- 168,174 ----
("/resmgr\\.conf" . "class\\|add\\|allow\\|deny")
("/dictionary\\.lst\\'" . "DICT\\|HYPH\\|THES")
("/tuxracer/options" . "set"))
! "File-name-based settings for the variable `conf-space-keywords'.")
(defvar conf-space-keywords nil
"Regexps for functions that may come before a space assignment.
***************
*** 188,194 ****
'(1 'font-lock-keyword-face)
'(2 'font-lock-variable-name-face))
'("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face)))
! "Keywords to hilight in Conf Space mode.")
(defvar conf-colon-font-lock-keywords
`(;; [section] (do this first because it may look like a parameter)
--- 188,194 ----
'(1 'font-lock-keyword-face)
'(2 'font-lock-variable-name-face))
'("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face)))
! "Keywords to highlight in Conf Space mode.")
(defvar conf-colon-font-lock-keywords
`(;; [section] (do this first because it may look like a parameter)
***************
*** 442,455 ****
(setq imenu-generic-expression
'(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1))))
- (defvar conf-space-keywords-override nil
- "Value to be put in `conf-space-keywords' after `conf-space-mode'.")
-
;;;###autoload
(define-derived-mode conf-space-mode conf-unix-mode "Conf[Space]"
"Conf Mode starter for space separated conf files.
\"Assignments\" are with ` '. Keywords before the parameters are
! recognized according to `conf-space-keywords'. Interactively
with a prefix ARG of `0' no keywords will be recognized. With
any other prefix arg you will be prompted for a regexp to match
the keywords.
--- 442,452 ----
(setq imenu-generic-expression
'(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1))))
;;;###autoload
(define-derived-mode conf-space-mode conf-unix-mode "Conf[Space]"
"Conf Mode starter for space separated conf files.
\"Assignments\" are with ` '. Keywords before the parameters are
! recognized according to the variable `conf-space-keywords'. Interactively
with a prefix ARG of `0' no keywords will be recognized. With
any other prefix arg you will be prompted for a regexp to match
the keywords.
***************
*** 471,489 ****
(make-local-variable 'conf-assignment-sign)
(setq conf-assignment-sign nil)
(make-local-variable 'conf-space-keywords)
! (make-local-variable 'conf-space-keywords-override)
! (setq conf-space-keywords-override nil)
! (cond (current-prefix-arg
! ;; By setting conf-space-keywords-override
! ;; we arrange for conf-space-mode-internal
! ;; to override any value of conf-space-keywords
! ;; specified in a local variables list.
! (setq conf-space-keywords-override
! (if (> (prefix-numeric-value current-prefix-arg) 0)
! (read-string "Regexp to match keywords: "))))
! ;; If this is already set, don't replace it with the default.
! (conf-space-keywords)
! (buffer-file-name
;; By setting conf-space-keywords directly,
;; we let a value in the local variables list take precedence.
(make-local-variable 'conf-space-keywords)
--- 468,474 ----
(make-local-variable 'conf-assignment-sign)
(setq conf-assignment-sign nil)
(make-local-variable 'conf-space-keywords)
! (cond (buffer-file-name
;; By setting conf-space-keywords directly,
;; we let a value in the local variables list take precedence.
(make-local-variable 'conf-space-keywords)
***************
*** 493,505 ****
(conf-space-mode-internal)
;; In case the local variables list specifies conf-space-keywords,
;; recompute other things from that afterward.
! (push 'conf-space-mode-internal
! hack-local-variables-hook))
(defun conf-space-mode-internal ()
- (when conf-space-keywords-override
- (setq conf-space-keywords
- conf-space-keywords-override))
(make-local-variable 'conf-assignment-regexp)
(setq conf-assignment-regexp
(if conf-space-keywords
--- 478,500 ----
(conf-space-mode-internal)
;; In case the local variables list specifies conf-space-keywords,
;; recompute other things from that afterward.
! (add-hook 'hack-local-variables-hook 'conf-space-mode-internal))
!
! (defun conf-space-keywords (keywords)
! "Enter Conf Space mode using regexp KEYWORDS to match the keywords.
! See `conf-space-mode'."
! (interactive "sConf Space keyword regexp: ")
!
! (conf-mode-initialize "#" 'conf-space-font-lock-keywords)
! (make-local-variable 'conf-assignment-sign)
! (setq conf-assignment-sign nil)
! (make-local-variable 'conf-space-keywords)
! (setq conf-space-keywords keywords)
! (conf-space-mode-internal)
! ;; Don't let this hook run and override us.
! (remove-hook 'hack-local-variables-hook 'conf-space-mode-internal))
(defun conf-space-mode-internal ()
(make-local-variable 'conf-assignment-regexp)
(setq conf-assignment-regexp
(if conf-space-keywords
***************
*** 511,524 ****
(boundp 'font-lock-keywords)) ;see `normal-mode'
(font-lock-add-keywords nil nil)
(font-lock-mode 1))
(setq imenu-generic-expression
! `(,@(cdr imenu-generic-expression)
! ("Parameters"
! ,(if conf-space-keywords
! (concat "^[ \t]*\\(?:" conf-space-keywords
! "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
! "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
! 1))))
;;;###autoload
(define-derived-mode conf-colon-mode conf-unix-mode "Conf[Colon]"
--- 506,526 ----
(boundp 'font-lock-keywords)) ;see `normal-mode'
(font-lock-add-keywords nil nil)
(font-lock-mode 1))
+ ;; Copy so that we don't destroy shared structure.
+ (setq imenu-generic-expression (copy-sequence imenu-generic-expression))
+ ;; Get rid of any existing Parameters element.
+ (setq imenu-generic-expression
+ (delq (assoc "Parameters" imenu-generic-expression)
+ imenu-generic-expression))
+ ;; Add a new one based on conf-space-keywords.
(setq imenu-generic-expression
! (cons `("Parameters"
! ,(if conf-space-keywords
! (concat "^[ \t]*\\(?:" conf-space-keywords
! "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
! "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
! 1)
! imenu-generic-expression)))
;;;###autoload
(define-derived-mode conf-colon-mode conf-unix-mode "Conf[Colon]"
next prev parent reply other threads:[~2006-09-15 14:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-10 13:04 conf-space-mode Richard Stallman
2006-09-11 1:06 ` conf-space-mode Wolfgang Jenkner
2006-09-11 19:58 ` conf-space-mode Richard Stallman
2006-09-12 5:32 ` conf-space-mode Wolfgang Jenkner
2006-09-15 14:29 ` Richard Stallman [this message]
2006-09-16 13:45 ` conf-space-mode Wolfgang Jenkner
2006-09-16 19:05 ` conf-space-mode Richard Stallman
2006-09-18 11:00 ` conf-space-mode Wolfgang Jenkner
2006-09-18 18:52 ` conf-space-mode Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1GOEhI-000733-9T@fencepost.gnu.org \
--to=rms@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).