Subject: 24.5; nxml-mode should support shift selection
From: Yuri Khan <[email-masked]>
To: [email-masked]
Date: Mon, 10 Oct 2016 22:41:37 +0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Many movement commands, such as forward-word, forward-sexp,
forward-sentence, next-line, and their backward counterparts, support
shift selection. That is, holding down Shift along with their bindings
causes region to be activated and/or extended.

$ emacs -Q

C-x C-f /tmp/test.xml

    <html>|<head></head><body></body></html>

C-M-S-<right> ;; C-M-<right> (translated) runs forward-sexp

    <html>[<head>]</head><body></body></html>

C-M-S-<right> ;; C-M-<right> (translated) runs forward-sexp

    <html>[<head></head>]<body></body></html>

However, nxml-mode’s commands do not behave this way.

    <html>|<head></head><body></body></html>

C-M-S-n ;; C-M-n (translated) runs nxml-forward-element

Expected:

    <html>[<head></head>]<body></body></html>

Observed:

    <html><head></head>|<body></body></html>

The attached patch fixes this for me. It is based on current master (fd45b3f).
From 35175026f4809af9e711ba9a47a6214932473aaf Mon Sep 17 00:00:00 2001
From: Yuri Khan <[email-masked]>
Date: Mon, 10 Oct 2016 23:14:42 +0700
Subject: [PATCH] lisp/nxml/nxml-mode: Support Shift selection

---
 lisp/nxml/nxml-mode.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index cceb75e..0b9975f 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1521,7 +1521,7 @@ references and character references.  A processing instruction
 consists of a target and a content string.  A comment or a CDATA
 section contains a single string.  An entity reference contains a
 single name.  A character reference contains a character number."
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (cond ((> arg 0)
 	 (while (progn
@@ -1733,7 +1733,7 @@ single name.  A character reference contains a character number."
     ret))
 
 (defun nxml-up-element (&optional arg)
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (if (< arg 0)
       (nxml-backward-up-element (- arg))
@@ -1761,7 +1761,7 @@ single name.  A character reference contains a character number."
        (apply #'error (cddr err))))))
 
 (defun nxml-backward-up-element (&optional arg)
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (if (< arg 0)
       (nxml-up-element (- arg))
@@ -1793,7 +1793,7 @@ single name.  A character reference contains a character number."
   "Move forward down into the content of an element.
 With ARG, do this that many times.
 Negative ARG means move backward but still down."
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (if (< arg 0)
       (nxml-backward-down-element (- arg))
@@ -1811,7 +1811,7 @@ Negative ARG means move backward but still down."
       (setq arg (1- arg)))))
 
 (defun nxml-backward-down-element (&optional arg)
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (if (< arg 0)
       (nxml-down-element (- arg))
@@ -1839,7 +1839,7 @@ Negative ARG means move backward but still down."
   "Move forward over one element.
 With ARG, do it that many times.
 Negative ARG means move backward."
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (if (< arg 0)
       (nxml-backward-element (- arg))
@@ -1858,7 +1858,7 @@ Negative ARG means move backward."
   "Move backward over one element.
 With ARG, do it that many times.
 Negative ARG means move forward."
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (if (< arg 0)
       (nxml-forward-element (- arg))
@@ -1893,7 +1893,7 @@ The paragraph marked is the one that contains point or follows point."
   (nxml-backward-paragraph))
 
 (defun nxml-forward-paragraph (&optional arg)
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (cond ((< arg 0)
 	 (nxml-backward-paragraph (- arg)))
@@ -1903,7 +1903,7 @@ The paragraph marked is the one that contains point or follows point."
 		     (> (setq arg (1- arg)) 0))))))
 
 (defun nxml-backward-paragraph (&optional arg)
-  (interactive "p")
+  (interactive "^p")
   (or arg (setq arg 1))
   (cond ((< arg 0)
 	 (nxml-forward-paragraph (- arg)))
-- 
2.10.1