unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* POC comment/uncomment region in nxml-mode
@ 2014-07-22 23:22 Tim Chambers
  2014-07-23  6:36 ` Andreas Röhler
  2014-08-18 15:31 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Tim Chambers @ 2014-07-22 23:22 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-20 14:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-22 23:22 POC comment/uncomment region in nxml-mode Tim Chambers
2014-07-23  6:36 ` Andreas Röhler
2014-08-18 15:31 ` Stefan Monnier
2014-08-19 15:12   ` Tim Chambers
2014-08-20 14:13     ` Stefan Monnier

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).