unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* conf-space-mode
@ 2006-09-10 13:04 Richard Stallman
  2006-09-11  1:06 ` conf-space-mode Wolfgang Jenkner
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2006-09-10 13:04 UTC (permalink / raw)
  Cc: emacs-devel

I think I fixed the bug you reported
and also got rid of the excess requests for
confirmation.  Would you please test the changes
I checked in?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-10 13:04 conf-space-mode Richard Stallman
@ 2006-09-11  1:06 ` Wolfgang Jenkner
  2006-09-11 19:58   ` conf-space-mode Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Jenkner @ 2006-09-11  1:06 UTC (permalink / raw)


Richard Stallman <rms@gnu.org> writes:

> I think I fixed the bug you reported and also got rid of the excess
> requests for confirmation.

The way you state this suggests that perhaps you forgot that I
actually sent a patch?

> Would you please test the changes I checked in?

You didn't address the problematic use of `current-prefix-arg'.

For ease of reference (and since you started a new thread) I include
here my original message `patch for conf-space-mode glitches' from
Mon, 04 Sep 2006 23:47:56 +0200:

Create a file (say, ./x) with the following content:

# -*-conf-*-

foo bar quux

# Local Variables:
# conf-space-keywords: "foo"
# End:

Visit it: C-x C-f x <return> y y

There is an inconvenience here, viz. that (by design) you are asked
twice about the same Local Variables.

Anyway, `foo' has the `font-lock-keyword-face' face text-property now
and is correctly highlighted.

Now type: C-u C-c SPC n f o o <return>

IIUC the result should be the same as above.  However `foo' has the
`font-lock-variable-name-face' face text-property instead (also, it
doesn't make sense to ask about the Local Variables here).

On the other hand,

C-u C-x C-v <return> n f o o <return> n

does give the expected result.  However, passing down like this the
prefix arg from a different command is quite problematic; for example,
`ffap-bindings' rebinds C-x C-f to `find-file-at-point', which also
plays tricks with `current-prefix-arg'.  In particular,

C-u C-x C-f / f t p . f o o . b a r : RET

surprises by asking for a "Regexp to match keywords: " (if you have a
valid ~/.netrc `ange-ftp-parse-netrc' inserts it in a buffer and calls
`normal-mode' etc.)

The following patch makes `conf-space-mode' behave like other modes,
while still not contradicting what is documented in the docstrings.
The disadvantage is that people who put some `conf-space-keywords'
dependent function on `conf-space-mode-hook' have to do some more work
now; see the comment at the end of the patch below.

Index: conf-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/conf-mode.el,v
retrieving revision 1.14
diff -c -r1.14 conf-mode.el
*** conf-mode.el	6 Feb 2006 12:12:26 -0000	1.14
--- conf-mode.el	4 Sep 2006 19:37:58 -0000
***************
*** 190,195 ****
--- 190,199 ----
  	  '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face)))
    "Keywords to hilight in Conf Space mode.")
  
+ (defvar conf-space-change-flag nil
+   "Holds what the last call to `conf-space-hack-keywords' returned.
+ Might be useful if you put more stuff on `hack-local-variables-hook'.")
+ 
  (defvar conf-colon-font-lock-keywords
    `(;; [section] (do this first because it may look like a parameter)
      ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face)
***************
*** 467,498 ****
    (conf-mode-initialize "#" 'conf-space-font-lock-keywords)
    (set (make-local-variable 'conf-assignment-sign)
         nil)
!   ;; This doesn't seem right, but the next two depend on conf-space-keywords
!   ;; being set, while after-change-major-mode-hook might set up imenu, needing
!   ;; the following result:
!   (hack-local-variables-prop-line)
!   (hack-local-variables)
!   (cond (current-prefix-arg
!          (set (make-local-variable 'conf-space-keywords)
!               (if (> (prefix-numeric-value current-prefix-arg) 0)
!                   (read-string "Regexp to match keywords: "))))
!         (conf-space-keywords)
!         (buffer-file-name
!          (set (make-local-variable 'conf-space-keywords)
!               (assoc-default buffer-file-name conf-space-keywords-alist
!                              'string-match))))
!   (set (make-local-variable 'conf-assignment-regexp)
!        (if conf-space-keywords
! 	   (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)")
! 	 ".+?\\([ \t]+\\|$\\)"))
!   (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]"
--- 471,533 ----
    (conf-mode-initialize "#" 'conf-space-font-lock-keywords)
    (set (make-local-variable 'conf-assignment-sign)
         nil)
!   (let ((arg (and (eq this-command 'conf-space-mode) current-prefix-arg)))
!     (cond (arg
! 	   (set (make-local-variable 'conf-space-keywords)
! 		(if (> (prefix-numeric-value current-prefix-arg) 0)
! 		    (read-string "Regexp to match keywords: "))))
! 	  (conf-space-keywords)		;A global value.  Useful?
! 	  (buffer-file-name
! 	   (set (make-local-variable 'conf-space-keywords)
! 		(assoc-default buffer-file-name conf-space-keywords-alist
! 			       'string-match))))
!     (conf-space-hack-keywords t)
!     (unless arg
!       (add-hook 'hack-local-variables-hook 'conf-space-hack-keywords nil t))))
! 
! 
! (defun conf-space-hack-keywords (&optional mode-flag)
!   "Initialize or adjust variables depending on `conf-space-keywords'.
! Returns non-nil iff MODE-FLAG is nil and something actually changed."
!   (when (or mode-flag (eq major-mode 'conf-space-mode))
!     (let ((regexp (if conf-space-keywords
! 		      (concat "\\(?:" conf-space-keywords
! 			      "\\)[ \t]+.+?\\([ \t]+\\|$\\)")
! 		    ".+?\\([ \t]+\\|$\\)")))
!       (set (make-local-variable 'conf-space-change-flag)
! 	   (when (or mode-flag (not (string= conf-assignment-regexp regexp)))
! 	     (set (make-local-variable 'conf-assignment-regexp) regexp)
! 	     ;; Take care of `(eval ...)' in `conf-space-font-lock-keywords'.
! 	     (when (and font-lock-mode
! 			(boundp 'font-lock-keywords)) ;see `normal-mode'
! 	       (font-lock-add-keywords nil nil)
! 	       (font-lock-mode 1))
! 	     (setq imenu-generic-expression
! 		   `(,@(remq (assoc "Parameters" imenu-generic-expression)
! 			     imenu-generic-expression)
! 		     ("Parameters"
! 		      ,(if conf-space-keywords
! 			   (concat "^[ \t]*\\(?:" conf-space-keywords
! 				   "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
! 			 "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
! 		      1)))
! 	     (not mode-flag))))))
! 
! ;; A comment in the original `conf-space-mode' states: [...]
! ;; `after-change-major-mode-hook' might set up imenu, needing [some
! ;; stuff depending on `conf-space-keywords'].
! 
! ;; The following snippet makes sure 'after-change-major-mode-hook' is
! ;; run at an appropriate time, though I think it would be cleaner to
! ;; run specific functions instead of the whole hook.
! 
! ;; (add-hook 'conf-space-mode-hook
! ;;	  (lambda ()
! ;;	    (add-hook 'hack-local-variables-hook
! ;;		      (lambda ()
! ;;			(when conf-space-change-flag
! ;;			  (run-hooks 'after-change-major-mode-hook))) ;Yuck!
! ;;		      t t)))
  
  ;;;###autoload
  (define-derived-mode conf-colon-mode conf-unix-mode "Conf[Colon]"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-11  1:06 ` conf-space-mode Wolfgang Jenkner
@ 2006-09-11 19:58   ` Richard Stallman
  2006-09-12  5:32     ` conf-space-mode Wolfgang Jenkner
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2006-09-11 19:58 UTC (permalink / raw)
  Cc: emacs-devel

    The way you state this suggests that perhaps you forgot that I
    actually sent a patch?

I saw your patch but decided to fix the problem a different way.

    You didn't address the problematic use of `current-prefix-arg'.

Yes I did, in the second change.  The first one fixes the other
problem you mentioned, that of asking for confirmation twice.  You
used the words "by design" and I took that to mean you thought this
was a feature, so I assumed you had not tried to change this.  But I
considered it a bug.  So the first thing I did was fix this.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-11 19:58   ` conf-space-mode Richard Stallman
@ 2006-09-12  5:32     ` Wolfgang Jenkner
  2006-09-15 14:29       ` conf-space-mode Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Jenkner @ 2006-09-12  5:32 UTC (permalink / raw)


Richard Stallman <rms@gnu.org> writes:

>     The way you state this suggests that perhaps you forgot that I
>     actually sent a patch?
>
> I saw your patch but decided to fix the problem a different way.

Not very different, though.

>     You didn't address the problematic use of `current-prefix-arg'.
>
> Yes I did, in the second change.

I'm afraid we are not talking of the same problem here.

I think what you call the `second change' is making C-u C-c SPC work.

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'.  I gave a rather
surprising example of this situation, where the user might not be
aware of some config file being inserted in a buffer.  That example is
slightly bogus however since it actually works correctly with
'ffap-bindings'.  Here is something that should ahem... not work:

(ffap-bindings)
(setq ffap-require-prefix t)

Place point after the colon of ftp.foo.bar: and do C-u C-x C-f

My patch makes `conf-space-mode' heed the prefix argument only if it
is the actual command being executed.  I think this is enough since
you can always visit a config file and then do C-u C-c SPC to adjust
`conf-space-keywords'.  But then again, I never use this feature.

> The first one fixes the other problem you mentioned, that of asking
> for confirmation twice.  You used the words "by design" and I took
> that to mean you thought this was a feature, so I assumed you had
> not tried to change this.

You assumed?

>  But I considered it a bug.  So the first thing I did was fix this.

The imenu stuff is slightly broken now (given my test file x, try C-x
C-f x <return> y and observe that `imenu-generic-expression' has two
"Parameters" entries).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-12  5:32     ` conf-space-mode Wolfgang Jenkner
@ 2006-09-15 14:29       ` Richard Stallman
  2006-09-16 13:45         ` conf-space-mode Wolfgang Jenkner
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2006-09-15 14:29 UTC (permalink / raw)
  Cc: emacs-devel

    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]"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-15 14:29       ` conf-space-mode Richard Stallman
@ 2006-09-16 13:45         ` Wolfgang Jenkner
  2006-09-16 19:05           ` conf-space-mode Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Jenkner @ 2006-09-16 13:45 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> 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?
[...]
>     ;; 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))

I think this should be

(add-hook 'hack-local-variables-hook 'conf-space-mode-internal nil t)

[...]
> ! (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)

I'd suggest something like

(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: ")
  (delay-mode-hooks
    (conf-space-mode))
  (setq conf-space-keywords
	(if (equal keywords "")	;`if' instead of `unless' for clarity.
	    ;; An empty string is not useful here.
	    ;; So reset to the default.
	    nil
	  keywords))
  (conf-space-mode-internal)
  (run-mode-hooks))

But as I said, I don't use this feature at all, so this is just idle
speculation about what could be useful.

> !   ;; Don't let this hook run and override us.
> !   (remove-hook 'hack-local-variables-hook 'conf-space-mode-internal))

I dont't think this is necessary since the function
`conf-space-keywords' is not run as a result of calling `normal-mode'.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-16 13:45         ` conf-space-mode Wolfgang Jenkner
@ 2006-09-16 19:05           ` Richard Stallman
  2006-09-18 11:00             ` conf-space-mode Wolfgang Jenkner
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2006-09-16 19:05 UTC (permalink / raw)
  Cc: emacs-devel

    I think this should be

    (add-hook 'hack-local-variables-hook 'conf-space-mode-internal nil t)

You're right.

I will install these changes.  Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-16 19:05           ` conf-space-mode Richard Stallman
@ 2006-09-18 11:00             ` Wolfgang Jenkner
  2006-09-18 18:52               ` conf-space-mode Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Jenkner @ 2006-09-18 11:00 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> I will install these changes.  Thanks.

Here's some cleanup and a fix for a critical typo in `conf-space-keywords'.
There's also some whitespace cleanup, which shows up in the patch.

	* textmodes/conf-mode.el (conf-space-mode): Doc fix.
        Clarify comment.
        Delete duplicate make-local-variable form.
        (conf-space-keywords): Add autoload cookie.
        Fix typo (`keywords', not `keyword').

Index: conf-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/conf-mode.el,v
retrieving revision 1.17
diff -c -r1.17 conf-mode.el
*** conf-mode.el	16 Sep 2006 18:43:57 -0000	1.17
--- conf-mode.el	18 Sep 2006 10:39:20 -0000
***************
*** 446,455 ****
  (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.
  
  For details see `conf-mode'.  Example:
  
--- 446,456 ----
  (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-alist'.
! Alternatively, you can specify a value for the file local variable
! `conf-space-keywords'.
! Use the function `conf-space-keywords' if you want to specify keywords
! in an interactive fashion instead.
  
  For details see `conf-mode'.  Example:
  
***************
*** 469,478 ****
    (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)
!          (setq conf-space-keywords
  	       (assoc-default buffer-file-name conf-space-keywords-alist
  			      'string-match))))
    (conf-space-mode-internal)
--- 470,479 ----
    (setq conf-assignment-sign nil)
    (make-local-variable 'conf-space-keywords)
    (cond (buffer-file-name
! 	 ;; We set conf-space-keywords directly, but a value which is
! 	 ;; in the local variables list or interactively specified
! 	 ;; (see the function conf-space-keywords) takes precedence.
! 	 (setq conf-space-keywords
  	       (assoc-default buffer-file-name conf-space-keywords-alist
  			      'string-match))))
    (conf-space-mode-internal)
***************
*** 480,492 ****
    ;; recompute other things from that afterward.
    (add-hook 'hack-local-variables-hook 'conf-space-mode-internal nil t))
  
  (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: ")
    (delay-mode-hooks
      (conf-space-mode))
!   (if (string-equal keyword "")
        (setq keywords nil))
    (setq conf-space-keywords keywords)
    (conf-space-mode-internal)
--- 481,494 ----
    ;; recompute other things from that afterward.
    (add-hook 'hack-local-variables-hook 'conf-space-mode-internal nil t))
  
+ ;;;###autoload
  (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: ")
    (delay-mode-hooks
      (conf-space-mode))
!   (if (string-equal keywords "")
        (setq keywords nil))
    (setq conf-space-keywords keywords)
    (conf-space-mode-internal)
***************
*** 517,523 ****
  		     (concat "^[ \t]*\\(?:" conf-space-keywords
  			     "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
  		   "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
! 		1)	
  	      imenu-generic-expression)))
  
  ;;;###autoload
--- 519,525 ----
  		     (concat "^[ \t]*\\(?:" conf-space-keywords
  			     "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
  		   "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
! 		1)
  	      imenu-generic-expression)))
  
  ;;;###autoload

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: conf-space-mode
  2006-09-18 11:00             ` conf-space-mode Wolfgang Jenkner
@ 2006-09-18 18:52               ` Richard Stallman
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Stallman @ 2006-09-18 18:52 UTC (permalink / raw)
  Cc: emacs-devel

I installed your patch (since it is not big enough to need legal
papers).  Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-09-18 18:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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       ` conf-space-mode Richard Stallman
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

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).