emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

indenting in nxml-mode


From: Joseph Mingrone
Subject: indenting in nxml-mode
Date: Fri, 15 Jul 2016 22:30:19 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (berkeley-unix)

Hi,

I posted a question on emacs.stackexhcange.com about indenting in nxml-mode.

http://emacs.stackexchange.com/questions/24619/indent-continuation-lines-in-nxml-mode

My goal was to configure indenting to conform to the style guide described here.

https://www.freebsd.org/doc/en_US.ISO8859-1/books/fdp-primer/book.html#writing-style-guide

It seems this was not possible without some hacking.

I have given it a (very) preliminary attempt.  I suspect there are cases I
haven't considered, but after some light testing, it seems to be working.

(defun nxml-compute-indent-from-matching-start-tag ()
  "Compute the indent for a line using the matching start-tag."
  (save-excursion
    (back-to-indentation)
    (nxml-token-after)
    (let ((bol (point)) (bol-xmltok-type xmltok-type))
      (and
       (condition-case nil
           (nxml-scan-element-backward
            (point) t (- (point) nxml-end-tag-indent-scan-distance))
         (nxml-scan-error nil))
       (< xmltok-start bol)
       (progn
         (goto-char xmltok-start)
         (skip-chars-backward " \t")
         (bolp))
       (if (memq bol-xmltok-type
                 '(data empty-element partial-start-tag start-tag ))
           (+ (current-indentation) nxml-child-indent)
         (current-indentation))))))

What problems am I missing?

Joseph

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]