Loading ...
Sorry, an error occurred while loading the content.

Re: Emacs refuses to default to using nXML mode on HTML files

Expand Messages
  • drkm
    ... Off course, if your .emacs is shared between different Emacsen, you ... (when (boundp magic-mode-alist) (setq magic-mode-alist (delete-if (lambda (cell)
    Message 1 of 10 , Dec 31, 2004
    • 0 Attachment
      drkm <darkman_spam@...> writes:

      > The problem is that the default value use `html-mode', `sgml-mode'
      > and `xml-mode'. To remove them, here is what I have in my .emacs :

      Off course, if your .emacs is shared between different Emacsen, you
      have to test (boundp 'magic-mode-alist) :

      > (defcustom drkm-misc:magic-modes-to-delete '(html-mode sgml-mode xml-mode)
      > "List of mode symbols whose entries to delete in `magic-mode-alist'."
      > :type '(repeat symbol)
      > :group 'drkm)

      > (setq magic-mode-alist
      > (delete-if (lambda (cell)
      > (memq (cdr cell) drkm-misc:magic-modes-to-delete))
      > magic-mode-alist))

      (when (boundp 'magic-mode-alist)
      (setq magic-mode-alist
      (delete-if (lambda (cell)
      (memq (cdr cell) drkm-misc:magic-modes-to-delete))
      magic-mode-alist)))

      > And in my top-config-web.el :

      > (push '("\\`<\\?xml" . nxml-mode) magic-mode-alist)

      (when (boundp 'magic-mode-alist)
      (push '("\\`<\\?xml" . nxml-mode) magic-mode-alist))

      --drkm
    • jjramsey_6x9eq42
      ... the ... I just added this to my /~.emacs: ;; Avoid determining the mode by contents of file. ;; Emacs is too smart for its own good. (setq magic-mode-alist
      Message 2 of 10 , Jan 1, 2005
      • 0 Attachment
        --- In emacs-nxml-mode@yahoogroups.com, drkm <darkman_spam@y...>
        wrote:
        > David Abrahams <dave@b...> writes:
        >
        > > James J. Ramsey wrote:
        >
        > >> I already have this line in ~/.emacs:
        >
        > >> (setq auto-mode-alist (cons '("\\.html\\'" .
        > >> nxml-mode) auto-mode-alist))
        >
        > >> Somehow it's being overridden, and I don't know why.
        > >> When I start up Emacs and load an XHTML file,
        > >> sgml-mode gets applied to the file by default.
        > >> Autoloading nxml-mode doesn't help. (It's already
        > >> autoloaded by rng-auto.el, anyway.) If I type "M-x
        > >> nxml-mode", I can get nxml-mode to be applied to the
        > >> file; Emacs just won't do it by default.
        >
        > >> Any idea what's going on?
        >
        > > I had a similar problem recently.
        >
        > And your Emacsen are more recently than 2004-11-03. Right ?
        >
        > 2004-11-03 Daniel Pfeiffer <occitan@e...>
        >
        > * files.el (xml-based-modes): Delete var.
        > (magic-mode-alist): New more general var.
        > (set-auto-mode): Use it.
        >
        > `magic-mode-alist' is used before `auto-mode-alist' to look for a
        > regexp in the buffer to decide the mode to be used. Exactly like
        the
        > code Vincent proposed :
        >
        > (add-hook 'hack-local-variables-hook
        > (lambda ()
        > (save-excursion
        > (when (search-forward-regexp "^<\\?xml" 6 0)
        > (nxml-mode)
        > ))))
        >
        > becoming :
        >
        > (push '("\\`<\\?xml" . nxml-mode) magic-mode-alist)

        I just added this to my /~.emacs:

        ;; Avoid determining the mode by contents of file.
        ;; Emacs is too smart for its own good.
        (setq magic-mode-alist nil)

        A blunt solution, but it works.
      • drkm
        ... ~/.emacs :-) ... Yes. But: - it removes all entries from `magic-mode-alist , not only those regarding `html-mode , `sgml-mode and `xml-mode . After
        Message 3 of 10 , Jan 2, 2005
        • 0 Attachment
          "jjramsey_6x9eq42" <jjramsey_6x9eq42@...> writes:

          > I just added this to my /~.emacs:

          ~/.emacs :-)

          > ;; Avoid determining the mode by contents of file.
          > ;; Emacs is too smart for its own good.
          > (setq magic-mode-alist nil)

          > A blunt solution, but it works.

          Yes. But:

          - it removes all entries from `magic-mode-alist', not only those
          regarding `html-mode', `sgml-mode' and `xml-mode'. After
          removing these entries, the value remains :

          (("%![^V]" . ps-mode)
          ("# xmcd " . conf-unix-mode))

          - it doesn't benefit from this variable. In my configuration, I
          have :

          (push '("<\\?xml" . nxml-mode) magic-mode-alist)

          to launch nXML for files beginning by "<?xml".

          Note I wrote "<\\?xml", and not "\\`<\\?xml", as I wrote in my
          previous message. The match from `magic-mode-alist' is anchored at
          the beginning of the buffer, but it's not documented.

          --drkm
        • jjramsey_6x9eq42
          ... I know. That s why it s a blunt solution.
          Message 4 of 10 , Jan 2, 2005
          • 0 Attachment
            --- In emacs-nxml-mode@yahoogroups.com, drkm <darkman_spam@y...> wrote:
            > "jjramsey_6x9eq42" <jjramsey_6x9eq42@y...> writes:
            >
            > > I just added this to my /~.emacs:
            >
            > ~/.emacs :-)
            >
            > > ;; Avoid determining the mode by contents of file.
            > > ;; Emacs is too smart for its own good.
            > > (setq magic-mode-alist nil)
            >
            > > A blunt solution, but it works.
            >
            > Yes. But:
            >
            > - it removes all entries from `magic-mode-alist', not only those
            > regarding `html-mode', `sgml-mode' and `xml-mode'.

            I know. That's why it's a blunt solution.
          Your message has been successfully submitted and would be delivered to recipients shortly.