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

Re: using the dang thing

Expand Messages
  • aamehl
    ... I googled for it and can t figure out how to make it fly. here s what I got: You can align text on a character, such as a tab. First, mark (i.e. select)
    Message 1 of 9 , Nov 22, 2004
    • 0 Attachment
      > What about just using align-regexp to align the <measure> elements?
      > Would that work?
      >

      I googled for it and can't figure out how to make it fly.
      here's what I got:
      You can align text on a character, such as a tab. First, mark (i.e.
      select) your region to be aligned. You can drag your mouse over the
      region accomplish this. Next,
      M-x
      align-regexp
      C-q TAB

      Here is an example:

      Emacs $0.00
      Word $199.99
      Oracle Studio $30,000.00

      I don't understand the emacs lingo here what do they mean by C-q TAB

      Also if I get this working how can I hot wire it to a relaxng schema
      or a nxml-mode file so that all files of pattern x will use this
      alignment?

      Thanks
      Also is there a way to colorize by attribute or by a specific tag name
      for example I want

      <part name="oboe"></part> to be red
      and
      <part name="violin"></part> to be green

      or <part></part> to be blue
      and <measure></measure> to be orange

      I checked a bunch of commercial editors and they seem to only support
      all elements the same color and all atributes the same color. I
      realize this could get annoying if overused but it would sure make
      editing much easier.

      Aaron

      > --
      > Rohan Lloyd
    • Rohan Lloyd
      ... Try M-x describe-function align-regexp align-regexp is an interactive autoloaded Lisp function in `align . (align-regexp beg end regexp &optional group
      Message 2 of 9 , Nov 23, 2004
      • 0 Attachment
        On 23 Nov 2004, at 5:26 PM, aamehl wrote:
        >
        >> What about just using align-regexp to align the <measure> elements?
        >> Would that work?
        >
        > I googled for it and can't figure out how to make it fly.

        Try M-x describe-function align-regexp

        align-regexp is an interactive autoloaded Lisp function in `align'.
        (align-regexp beg end regexp &optional group spacing repeat)
        ...

        You should be able to defun a function to align your <measure> elements
        (or any elements) with something like:

        (defun align-element ()
        (interactive)
        "Align selected text on XML elements"
        (align-regexp (point) (mark) "<[A-Za-z]" 1 1 t))

        However, not being an emacs guru myself, I can't get this to work. I
        get a "Bad Argument" error.

        Getting back on topic for nxml-mode, the align package supports much
        more than align-regexp. It is possible to define a set of alignment
        rules and bind them to a mode.

        align come preconfigured with alignment rules for c++, perl, tex etc.
        Other packages can add there own rules.

        Here's the example from align.el

        ;; (require 'align)
        ;;
        ;; (defcustom my-align-rules-list
        ;; '((my-rule
        ;; (regexp . "Sample")))
        ;; :type align-rules-list-type
        ;; :group 'my-package)
        ;;
        ;; (put 'my-align-rules-list 'risky-local-variable t)
        ;;
        ;; (add-to-list 'align-dq-string-modes 'my-package-mode)
        ;; (add-to-list 'align-open-comment-modes 'my-package-mode)
        ;;
        ;; (defun my-mode ()
        ;; ...
        ;; (setq align-mode-rules-list my-align-rules-list))

        Would it make sense to add some alignment rules to nxml-mode?

        Just off the top of my head I can think of a few things that might make
        sense to align:

        • tag-start - this would align your <measure> elements. It might also
        be useful for things like <td> elements in a table

        • attributes? I'm not sure I'm sold on the idea, but if you have a lot
        of attributes, you may wish to align them something like:

        <foo attribute-a="foo" attribute-b="bar"
        attribute-c="blah"
        another-attribute="something" and-another="something-else"
        foo="bar"

        • close-comment - Instead of:

        <!-- This is a multi line comment -->
        <!-- the start of the comment lines up -->
        <!-- nicely, but what about the end? -->

        you get:

        <!-- This is a multi line comment -->
        <!-- the start of the comment lines up -->
        <!-- nicely, but what about the end? -->

        --
        Rohan Lloyd
      • aamehl
        Thanks, This will take me a while to digest. But indeed once I finish fleshing out the actual lilyxml relaxng having the mode define alignment will be great.
        Message 3 of 9 , Nov 23, 2004
        • 0 Attachment
          Thanks,

          This will take me a while to digest.

          But indeed once I finish fleshing out the actual lilyxml relaxng

          having the mode define alignment will be great.

          Next is how to selectively colorize elements and attributes, any ideas

          Thanks
          Aaron

          --- In emacs-nxml-mode@yahoogroups.com, Rohan Lloyd <nxml-mode@r...>
          wrote:
          >
          > On 23 Nov 2004, at 5:26 PM, aamehl wrote:
          > >
          > >> What about just using align-regexp to align the <measure> elements?
          > >> Would that work?
          > >
          > > I googled for it and can't figure out how to make it fly.
          >
          > Try M-x describe-function align-regexp
          >
          > align-regexp is an interactive autoloaded Lisp function in `align'.
          > (align-regexp beg end regexp &optional group spacing repeat)
          > ...
          >
          > You should be able to defun a function to align your <measure> elements
          > (or any elements) with something like:
          >
          > (defun align-element ()
          > (interactive)
          > "Align selected text on XML elements"
          > (align-regexp (point) (mark) "<[A-Za-z]" 1 1 t))
          >
          > However, not being an emacs guru myself, I can't get this to work. I
          > get a "Bad Argument" error.
          >
          > Getting back on topic for nxml-mode, the align package supports much
          > more than align-regexp. It is possible to define a set of alignment
          > rules and bind them to a mode.
          >
          > align come preconfigured with alignment rules for c++, perl, tex etc.
          > Other packages can add there own rules.
          >
          > Here's the example from align.el
          >
          > ;; (require 'align)
          > ;;
          > ;; (defcustom my-align-rules-list
          > ;; '((my-rule
          > ;; (regexp . "Sample")))
          > ;; :type align-rules-list-type
          > ;; :group 'my-package)
          > ;;
          > ;; (put 'my-align-rules-list 'risky-local-variable t)
          > ;;
          > ;; (add-to-list 'align-dq-string-modes 'my-package-mode)
          > ;; (add-to-list 'align-open-comment-modes 'my-package-mode)
          > ;;
          > ;; (defun my-mode ()
          > ;; ...
          > ;; (setq align-mode-rules-list my-align-rules-list))
          >
          > Would it make sense to add some alignment rules to nxml-mode?
          >
          > Just off the top of my head I can think of a few things that might make
          > sense to align:
          >
          > • tag-start - this would align your <measure> elements. It might also
          > be useful for things like <td> elements in a table
          >
          > • attributes? I'm not sure I'm sold on the idea, but if you have a lot
          > of attributes, you may wish to align them something like:
          >
          > <foo attribute-a="foo" attribute-b="bar"
          > attribute-c="blah"
          > another-attribute="something" and-another="something-else"
          > foo="bar"
          >
          > • close-comment - Instead of:
          >
          > <!-- This is a multi line comment -->
          > <!-- the start of the comment lines up -->
          > <!-- nicely, but what about the end? -->
          >
          > you get:
          >
          > <!-- This is a multi line comment -->
          > <!-- the start of the comment lines up -->
          > <!-- nicely, but what about the end? -->
          >
          > --
          > Rohan Lloyd
        Your message has been successfully submitted and would be delivered to recipients shortly.