unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [mp26@os.inf.tu-dresden.de: Patch for sgml-mode.el]
@ 2007-11-23  4:36 Richard Stallman
  2007-11-23 15:02 ` Fwd: Patch for sgml-mode.el Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Stallman @ 2007-11-23  4:36 UTC (permalink / raw)
  To: emacs-devel

Would someone please DTRT then ack?

------- Start of forwarded message -------
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 
	autolearn=failed version=3.1.0
Message-ID: <47457D57.7010008@os.inf.tu-dresden.de>
Date: Thu, 22 Nov 2007 14:00:07 +0100
From: Martin Pohlack <mp26@os.inf.tu-dresden.de>
MIME-Version: 1.0
To: bug-gnu-emacs@gnu.org
Content-Type: multipart/mixed; boundary="------------040006040108080505080703"
Subject: Patch for sgml-mode.el

This is a multi-part message in MIME format.
- --------------040006040108080505080703
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

Hi,

sgml-mode.el currently contains such lines:

(define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")

and

(define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
.

This violates that the third argument of define-derived-mode shall be a
string.  Furthermore, it results in "mode-name" not being a string for
html buffers.

The attached small patch against current CVS fixes these problems.

Cheers,
Martin Pohlack


- --------------040006040108080505080703
Content-Type: text/plain;
 name="sgml-mode_mode-name-fix.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="sgml-mode_mode-name-fix.diff"

- --- sgml-mode.el	2007-11-22 13:52:32.000000000 +0100
+++ /usr/share/emacs/23.0.60/lisp/textmodes/sgml-mode.el	2007-11-22 13:50:10.000000000 +0100
@@ -408,7 +406,7 @@
 	 (eq (char-before) ?<))))
 
 ;;;###autoload
- -(define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")
+(define-derived-mode sgml-mode text-mode (if sgml-xml-mode '"XML" '"SGML")
   "Major mode for editing SGML documents.
 Makes > match <.
 Keys <, &, SPC within <>, \", / and ' can be electric depending on
@@ -1890,7 +1888,7 @@
 
 \f
 ;;;###autoload
- -(define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
+(define-derived-mode html-mode sgml-mode (if sgml-xml-mode '"XHTML" '"HTML")
   "Major mode based on SGML mode for editing HTML documents.
 This allows inserting skeleton constructs used in hypertext documents with
 completion.  See below for an introduction to HTML.  Use

- --------------040006040108080505080703--
------- End of forwarded message -------

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-23  4:36 [mp26@os.inf.tu-dresden.de: Patch for sgml-mode.el] Richard Stallman
@ 2007-11-23 15:02 ` Stefan Monnier
  2007-11-23 15:26   ` Martin Pohlack
  2007-11-23 19:55   ` Glenn Morris
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Monnier @ 2007-11-23 15:02 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: rms, emacs-devel

> sgml-mode.el currently contains such lines:

> (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")

> and

> (define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
> .

> This violates that the third argument of define-derived-mode shall be a
> string.  Furthermore, it results in "mode-name" not being a string for
> html buffers.

I don't see a problem with that.  It's obviously been done on purpose.
Please describe where it causes a problem so we can fix that spot.


        Stefan

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-23 15:02 ` Fwd: Patch for sgml-mode.el Stefan Monnier
@ 2007-11-23 15:26   ` Martin Pohlack
  2007-11-23 16:26     ` Stefan Monnier
  2007-11-23 19:55   ` Glenn Morris
  1 sibling, 1 reply; 10+ messages in thread
From: Martin Pohlack @ 2007-11-23 15:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: rms, emacs-devel

Stefan Monnier wrote:
>> sgml-mode.el currently contains such lines:
> 
>> (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")
> 
>> and
> 
>> (define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
>> .
> 
>> This violates that the third argument of define-derived-mode shall be a
>> string.  Furthermore, it results in "mode-name" not being a string for
>> html buffers.
> 
> I don't see a problem with that.  It's obviously been done on purpose.

Well, this was not obvious to me ...

> Please describe where it causes a problem so we can fix that spot.

Most obviously: the documentation for "define-derived-mode" states:

  (define-derived-mode child parent name &optional docstring &rest body)

  ...

  name: a string which will appear in the status line (e.g. "Hypertext")

So name should be a string.

Second, I could not find the documentation for the varibale mode-name in
emacs, but in xemacs it is documented as:

  Pretty name of current buffer's major mode (a string).

Third, I have a buffer-switching module here locally, which relies on
mode-name being a string.

  http://os.inf.tu-dresden.de/~mp26/download/cycbuf.el

Could you advice another way to get the mode-name as a string for a
buffer apart from accessing mode-name?  Maybe this could be documented?

Cheers,
Martin

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-23 15:26   ` Martin Pohlack
@ 2007-11-23 16:26     ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2007-11-23 16:26 UTC (permalink / raw)
  To: Martin Pohlack; +Cc: rms, emacs-devel

> Third, I have a buffer-switching module here locally, which relies on
> mode-name being a string.

>   http://os.inf.tu-dresden.de/~mp26/download/cycbuf.el

> Could you advice another way to get the mode-name as a string for a
> buffer apart from accessing mode-name?  Maybe this could be documented?

Try (format-mode-line mode-name)


        Stefan

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-23 15:02 ` Fwd: Patch for sgml-mode.el Stefan Monnier
  2007-11-23 15:26   ` Martin Pohlack
@ 2007-11-23 19:55   ` Glenn Morris
  2007-11-30  4:46     ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2007-11-23 19:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Martin Pohlack, rms, emacs-devel

Stefan Monnier wrote:

>> Furthermore, it results in "mode-name" not being a string
>> for html buffers.
>
> I don't see a problem with that.  It's obviously been done on purpose.
> Please describe where it causes a problem so we can fix that spot.

I have being meaning to post about this.

See for example

http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00891.html

  From:   h1t
  Subject:    Bug in ibuffer-mark-by-mode-regexp function
  Date:       Wed, 14 Nov 2007 10:27:04 +0200

A quick grep for mode-name in lisp/ appears to show several places
that assume it is a string. It's documented as being a string, so I
would think at the very least should be a NEWS entry saying it might
not be any more.

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-23 19:55   ` Glenn Morris
@ 2007-11-30  4:46     ` Stefan Monnier
  2007-11-30 20:58       ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2007-11-30  4:46 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Martin Pohlack, rms, emacs-devel

>>>>> "GM" == Glenn Morris <rgm@gnu.org> writes:

> Stefan Monnier wrote:
>>> Furthermore, it results in "mode-name" not being a string
>>> for html buffers.
>> 
>> I don't see a problem with that.  It's obviously been done on purpose.
>> Please describe where it causes a problem so we can fix that spot.

> I have being meaning to post about this.

> See for example

> http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00891.html

>   From:   h1t
>   Subject:    Bug in ibuffer-mark-by-mode-regexp function
>   Date:       Wed, 14 Nov 2007 10:27:04 +0200

> A quick grep for mode-name in lisp/ appears to show several places
> that assume it is a string. It's documented as being a string, so I
> would think at the very least should be a NEWS entry saying it might
> not be any more.

Does the patch below fix those problems?


        Stefan


Index: lisp/ibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/ibuffer.el,v
retrieving revision 1.88
diff -u -r1.88 ibuffer.el
--- lisp/ibuffer.el	19 Nov 2007 08:50:03 -0000	1.88
+++ lisp/ibuffer.el	30 Nov 2007 04:46:25 -0000
@@ -1722,7 +1722,7 @@
    ('mouse-face 'highlight
 		'keymap ibuffer-mode-name-map
 		'help-echo "mouse-2: filter by this mode"))
-  (format "%s" mode-name))
+  (format-mode-line mode-name))
 
 (define-ibuffer-column process
   (:summarizer
Index: lisp/ibuf-ext.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/ibuf-ext.el,v
retrieving revision 1.59
diff -u -r1.59 ibuf-ext.el
--- lisp/ibuf-ext.el	23 Oct 2007 15:54:06 -0000	1.59
+++ lisp/ibuf-ext.el	30 Nov 2007 04:46:25 -0000
@@ -1134,11 +1134,11 @@
   (string-lessp (downcase
 		  (with-current-buffer
 		      (car a)
-		    mode-name))
+		    (format-mode-line mode-name)))
 		(downcase
 		 (with-current-buffer
 		     (car b)
-		   mode-name))))
+		   (format-mode-line mode-name)))))
 
 ;;;###autoload (autoload 'ibuffer-do-sort-by-alphabetic "ibuf-ext")
 (define-ibuffer-sorter alphabetic
@@ -1386,7 +1386,7 @@
   (ibuffer-mark-on-buffer
    #'(lambda (buf)
        (with-current-buffer buf
-	 (string-match regexp mode-name)))))
+	 (string-match regexp (format-mode-line mode-name))))))
 
 ;;;###autoload
 (defun ibuffer-mark-by-file-name-regexp (regexp)

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-30  4:46     ` Stefan Monnier
@ 2007-11-30 20:58       ` Glenn Morris
  2007-12-01  3:16         ` Stefan Monnier
  2007-12-01  4:07         ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Glenn Morris @ 2007-11-30 20:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Martin Pohlack, rms, emacs-devel

Stefan Monnier wrote:

> Does the patch below fix those problems?

Well, it probably does, but does the incompatible change of allowing
mode-name to be a non-string bring any benefits?

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-30 20:58       ` Glenn Morris
@ 2007-12-01  3:16         ` Stefan Monnier
  2007-12-02 21:59           ` Glenn Morris
  2007-12-01  4:07         ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2007-12-01  3:16 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Martin Pohlack, rms, emacs-devel

>> Does the patch below fix those problems?
> Well, it probably does, but does the incompatible change of allowing
> mode-name to be a non-string bring any benefits?

The obvious one: no need to manually recompute the string when one of
its constituents changes.  I.e. sgml-xml-mode does not need to know that
enabling/disabling it can change the mode-name from/to SGML/XML or
HTML/XHTML.  Cleaner code, more obviously correct.

If you look at what Ibuffer does with its mode-name, you'll see that it
might also benefit from using this feature (tho I guess using
mode-line-process could be better so that the annotations don't show up
in the buffer's mode name in buffer lists).


        Stefan

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

* Re: Fwd: Patch for sgml-mode.el
  2007-11-30 20:58       ` Glenn Morris
  2007-12-01  3:16         ` Stefan Monnier
@ 2007-12-01  4:07         ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2007-12-01  4:07 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Martin Pohlack, rms, emacs-devel

>> Does the patch below fix those problems?
> Well, it probably does,

That I can tell, but I'd like for someone to confirm it.


        Stefan

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

* Re: Fwd: Patch for sgml-mode.el
  2007-12-01  3:16         ` Stefan Monnier
@ 2007-12-02 21:59           ` Glenn Morris
  0 siblings, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2007-12-02 21:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Martin Pohlack, rms, emacs-devel

Stefan Monnier wrote:

> The obvious one: no need to manually recompute the string when one of
> its constituents changes.  I.e. sgml-xml-mode does not need to know that
> enabling/disabling it can change the mode-name from/to SGML/XML or
> HTML/XHTML.  Cleaner code, more obviously correct.


I don't see that it's any cleaner than the following, but I'm not
going to argue about it.


*** sgml-mode.el.~1.129.~	2007-08-14 00:36:28.000000000 -0700
--- sgml-mode.el	2007-12-02 13:55:42.000000000 -0800
***************
*** 408,414 ****
  	 (eq (char-before) ?<))))
  
  ;;;###autoload
! (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")
    "Major mode for editing SGML documents.
  Makes > match <.
  Keys <, &, SPC within <>, \", / and ' can be electric depending on
--- 408,414 ----
  	 (eq (char-before) ?<))))
  
  ;;;###autoload
! (define-derived-mode sgml-mode text-mode "SGML"
    "Major mode for editing SGML documents.
  Makes > match <.
  Keys <, &, SPC within <>, \", / and ' can be electric depending on
***************
*** 462,468 ****
         'sgml-mode-facemenu-add-face-function)
    (set (make-local-variable 'sgml-xml-mode) (sgml-xml-guess))
    (if sgml-xml-mode
!       ()
      (set (make-local-variable 'skeleton-transformation-function)
           sgml-transformation-function))
    ;; This will allow existing comments within declarations to be
--- 462,468 ----
         'sgml-mode-facemenu-add-face-function)
    (set (make-local-variable 'sgml-xml-mode) (sgml-xml-guess))
    (if sgml-xml-mode
!       (setq mode-name "XML")
      (set (make-local-variable 'skeleton-transformation-function)
           sgml-transformation-function))
    ;; This will allow existing comments within declarations to be

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

end of thread, other threads:[~2007-12-02 21:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-23  4:36 [mp26@os.inf.tu-dresden.de: Patch for sgml-mode.el] Richard Stallman
2007-11-23 15:02 ` Fwd: Patch for sgml-mode.el Stefan Monnier
2007-11-23 15:26   ` Martin Pohlack
2007-11-23 16:26     ` Stefan Monnier
2007-11-23 19:55   ` Glenn Morris
2007-11-30  4:46     ` Stefan Monnier
2007-11-30 20:58       ` Glenn Morris
2007-12-01  3:16         ` Stefan Monnier
2007-12-02 21:59           ` Glenn Morris
2007-12-01  4:07         ` Stefan Monnier

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