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

Re: [emacs-nxml-mode] How to customize key combinations?

Expand Messages
  • Lennart Borgman
    ... If you use `nxml-mode-map you do not have to bother about this keybinding if you change mode: (add-hook nxml-mode-hook (lambda () (define-key
    Message 1 of 13 , Oct 19, 2005
      drkm wrote:

      >drkm wrote:
      >
      >
      >
      >> (add-hook 'nxml-mode-hook
      >> (lambda ()
      >> (interactive)
      >> (local-set-key (kbd "<TAB>") 'nxml-complete)))
      >>
      >>
      >
      > There's no need for 'interactive':
      >
      > (add-hook 'nxml-mode-hook
      > (lambda ()
      > (local-set-key (kbd "<TAB>") 'nxml-complete)))
      >
      >
      If you use `nxml-mode-map' you do not have to bother about this
      keybinding if you change mode:

      (add-hook 'nxml-mode-hook
      (lambda ()
      (define-key nxml-mode-map (kbd "<TAB>") 'nxml-complete)))
    • Lennart Borgman
      ... Eh, rule of thumb: test everything before mailing. This seems to work at least with the CVS version of Emacs: (add-hook nxml-mode-hook (lambda ()
      Message 2 of 13 , Oct 19, 2005
        Lennart Borgman wrote:

        >drkm wrote:
        >
        >
        >
        >>drkm wrote:
        >>
        >>
        >>
        >>
        >>
        >>> (add-hook 'nxml-mode-hook
        >>> (lambda ()
        >>> (interactive)
        >>> (local-set-key (kbd "<TAB>") 'nxml-complete)))
        >>>
        >>>
        >>>
        >>>
        >> There's no need for 'interactive':
        >>
        >> (add-hook 'nxml-mode-hook
        >> (lambda ()
        >> (local-set-key (kbd "<TAB>") 'nxml-complete)))
        >>
        >>
        >>
        >>
        >If you use `nxml-mode-map' you do not have to bother about this
        >keybinding if you change mode:
        >
        >(add-hook 'nxml-mode-hook
        > (lambda ()
        > (define-key nxml-mode-map (kbd "<TAB>") 'nxml-complete)))
        >
        >
        Eh, rule of thumb: test everything before mailing. This seems to work at
        least with the CVS version of Emacs:

        (add-hook 'nxml-mode-hook
        (lambda ()
        (define-key nxml-mode-map [(tab)] 'nxml-complete)))
      • Sunil Raja Bhushan
        Hi all, Thanks for the help. This one is working. Our files are source controlled too. This may be the reason why other methods are not working. ... Also just
        Message 3 of 13 , Oct 19, 2005
          Hi all,
          Thanks for the help. This one is working. Our files are source
          controlled too. This may be the reason why other methods are not working.

          > (add-hook 'nxml-mode-hook
          > (lambda ()
          > (define-key nxml-mode-map [(tab)] 'nxml-complete)))

          Also just saying "\t" instead of [(tab)] is also working.

          Thanks,
          Sunil
        • drkm
          ... No. You can use this if you want: (eval-after-load nxml-mode (define-key nxml-mode-map (kbd ) nxml-complete)) --drkm
          Message 4 of 13 , Oct 20, 2005
            Lennart Borgman wrote:

            > drkm wrote:

            > > (add-hook 'nxml-mode-hook
            > > (lambda ()
            > > (interactive)
            > > (local-set-key (kbd "<TAB>") 'nxml-complete)))

            > Is there any reason not to use `nxml-mode-map' to bind the keys?

            No. You can use this if you want:

            (eval-after-load "nxml-mode"
            '(define-key nxml-mode-map (kbd "<TAB>") 'nxml-complete))

            --drkm







            ___________________________________________________________________________
            Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
            Téléchargez cette version sur http://fr.messenger.yahoo.com
          • drkm
            ... I don t understand what you mean by if you change mode . ... If you want to modify directly the map, don t use the mode hook. Use instead
            Message 5 of 13 , Oct 20, 2005
              Lennart Borgman wrote:

              > drkm wrote:

              > > (add-hook 'nxml-mode-hook
              > > (lambda ()
              > > (local-set-key (kbd "<TAB>") 'nxml-complete)))

              > If you use `nxml-mode-map' you do not have to bother about this
              > keybinding if you change mode:

              I don't understand what you mean by "if you change mode".

              > (add-hook 'nxml-mode-hook
              > (lambda ()
              > (define-key nxml-mode-map (kbd "<TAB>") 'nxml-complete)))

              If you want to modify directly the map, don't use the mode hook. Use
              instead 'eval-after-load' or something similar.

              --drkm







              ___________________________________________________________________________
              Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
              Téléchargez cette version sur http://fr.messenger.yahoo.com
            • LENNART BORGMAN
              From: drkm ... I meant that maybe you would want to switch to some other xml editing mode than nxml-mode in Emacs.
              Message 6 of 13 , Oct 20, 2005
                From: drkm <darkman_spam@...>

                > Lennart Borgman wrote:
                >
                > > drkm wrote:
                >
                > > > (add-hook 'nxml-mode-hook
                > > > (lambda ()
                > > > (local-set-key (kbd "<TAB>") 'nxml-complete)))
                >
                > > If you use `nxml-mode-map' you do not have to bother about this
                > > keybinding if you change mode:
                >
                > I don't understand what you mean by "if you change mode".

                I meant that maybe you would want to switch to some other xml editing mode than nxml-mode in Emacs.
              • drkm
                ... Ok. But what s the problem with local-set-key in this case? What gain from directly modifying nxml-mode-map instead? --drkm
                Message 7 of 13 , Oct 20, 2005
                  LENNART BORGMAN wrote:

                  > From: drkm

                  > > Lennart Borgman wrote:

                  > > > If you use `nxml-mode-map' you do not have to bother about this
                  > > > keybinding if you change mode:

                  > > I don't understand what you mean by "if you change mode".

                  > I meant that maybe you would want to switch to some other xml editing
                  > mode than nxml-mode in Emacs.

                  Ok. But what's the problem with 'local-set-key' in this case? What
                  gain from directly modifying 'nxml-mode-map' instead?

                  --drkm







                  ___________________________________________________________________________
                  Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
                  Téléchargez cette version sur http://fr.messenger.yahoo.com
                • LENNART BORGMAN
                  From: drkm ... Thanks, I see what you mean now. I read the docstring about `local-set-key (C-h f local-set-key) and it says: The
                  Message 8 of 13 , Oct 20, 2005
                    From: drkm <darkman_spam@...>

                    > > > Lennart Borgman wrote:
                    >
                    > > > > If you use `nxml-mode-map' you do not have to bother about
                    > this
                    > > > > keybinding if you change mode:
                    >
                    > > > I don't understand what you mean by "if you change mode".
                    >
                    > > I meant that maybe you would want to switch to some other xml
                    > editing> mode than nxml-mode in Emacs.
                    >
                    > Ok. But what's the problem with 'local-set-key' in this case? What
                    > gain from directly modifying 'nxml-mode-map' instead?
                    >
                    > --drkm

                    Thanks, I see what you mean now. I read the docstring about `local-set-key' (C-h f local-set-key) and it says:

                    "The binding goes in the current buffer's local map,
                    which in most cases is shared with all other buffers in the same major mode"

                    So I guess that in most circumstances you can just as well use `local-set-key'.
                  Your message has been successfully submitted and would be delivered to recipients shortly.