unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tim Chambers <tbchambers@gmail.com>
To: emacs-devel@gnu.org
Subject: POC comment/uncomment region in nxml-mode
Date: Tue, 22 Jul 2014 17:22:23 -0600	[thread overview]
Message-ID: <CABoxX=yay2SGfAZEhC7wCgnRJBKVVOAsqXwBztnpa6Of1_ib7w@mail.gmail.com> (raw)

Here's a POC for interactively commenting/uncommenting a region in
nxml-mode. I guess if I wanted to submit this as an enhancement to
nxml-mode I'd have to properly integrate the functions into nXML mode.
Looking for motivation. Anyone interest in pursuing this?

(defun my-nxml-comment-region ()
  "comment a block if in nXML mode; else call comment-region"
  (interactive)
  ;; KLUDGE: should bind key in buffer, but I'm lazy
  (cond ((string-equal mode-name "nXML")
(save-excursion
  (narrow-to-region (point) (mark))
  (goto-point-min)
  (save-excursion (replace-string "--" "\\-\\-"))
  (insert "<!--\n")
  (goto-point-max)
  (insert "-->\n")
  (widen)))
(t (comment-region (point) (mark)))))

(defun my-nxml-uncomment-region ()
  "uncomment a block if in nXML mode; else call uncomment-region
assumes it was commented by my-nxml-comment-region"
  (interactive)
  ;; KLUDGE: should bind key in buffer, but I'm lazy
  (cond ((string-equal mode-name "nXML")
(save-excursion
  (search-backward "<!--\n")
  (delete-char 5)
  (let ((start (point)) end)
    (search-forward "-->\n")
    (delete-char -4)
    (setq end (point))
    (save-excursion (replace-string "\\-\\-" "--" nil start end)))))
(t (uncomment-region (point) (mark)))))

www.emacswiki.org/emacs/NxmlMode#toc13

– Tim Chambers 1E4AF729D5CEFFD0



             reply	other threads:[~2014-07-22 23:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22 23:22 Tim Chambers [this message]
2014-07-23  6:36 ` POC comment/uncomment region in nxml-mode Andreas Röhler
2014-08-18 15:31 ` Stefan Monnier
2014-08-19 15:12   ` Tim Chambers
2014-08-20 14:13     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABoxX=yay2SGfAZEhC7wCgnRJBKVVOAsqXwBztnpa6Of1_ib7w@mail.gmail.com' \
    --to=tbchambers@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).