From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Chambers Newsgroups: gmane.emacs.devel Subject: POC comment/uncomment region in nxml-mode Date: Tue, 22 Jul 2014 17:22:23 -0600 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1406071396 7014 80.91.229.3 (22 Jul 2014 23:23:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Jul 2014 23:23:16 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 23 01:23:11 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X9jOo-0002dY-Pl for ged-emacs-devel@m.gmane.org; Wed, 23 Jul 2014 01:23:10 +0200 Original-Received: from localhost ([::1]:41784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9jOo-0005M4-AA for ged-emacs-devel@m.gmane.org; Tue, 22 Jul 2014 19:23:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9jOk-0005Lz-KU for emacs-devel@gnu.org; Tue, 22 Jul 2014 19:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9jOj-0003lM-MQ for emacs-devel@gnu.org; Tue, 22 Jul 2014 19:23:06 -0400 Original-Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:47113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9jOj-0003lD-DW for emacs-devel@gnu.org; Tue, 22 Jul 2014 19:23:05 -0400 Original-Received: by mail-la0-f45.google.com with SMTP id ty20so297849lab.4 for ; Tue, 22 Jul 2014 16:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=/78VVWoUVSOsxTXI12+BzO1/SEE/p/5wKqYabMeDCeI=; b=THj1GLafie2t8sXYjQAq22FUeHIXTZSmSFSY2Gq/GFkIOnuCJ0xBu6LIDx/3CZ+Edm 6oBf5sm5GZl+zMqMPOn4BywDP+l8MT2LcMDGPEW2egTqJV45nY6uVFNGrcX51KeIu+3m Ttp4CR6/FBovHplbFurMV/AwK6LkUMXrO4gWamBbOdA/hHcK8RbFlftS/psPFM0xsa+c e9qFnFZSFgcfV6p5ba5rJ5yGws8DR6uvh+EiXxovHCVWC/zaxKwZu6p/fZdti1j2Tfqg gfQVi/JnE8GsmdPbBwUURRx1JTgxq75CDOc3RL1ZXraZ/aWXSyk9GYwkQ1omfPbEZyHz kFKg== X-Received: by 10.112.209.73 with SMTP id mk9mr35965753lbc.64.1406071383662; Tue, 22 Jul 2014 16:23:03 -0700 (PDT) Original-Received: by 10.152.201.196 with HTTP; Tue, 22 Jul 2014 16:22:23 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173082 Archived-At: 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") (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 -4) (setq end (point)) (save-excursion (replace-string "\\-\\-" "--" nil start end))))) (t (uncomment-region (point) (mark))))) www.emacswiki.org/emacs/NxmlMode#toc13 =E2=80=93 Tim Chambers 1E4AF729D5CEFFD0