Selaa lähdekoodia

Lists: Make promotion and demotion work on regions.

Carsten Dominik 16 vuotta sitten
vanhempi
commit
01a061c2fa
4 muutettua tiedostoa jossa 40 lisäystä ja 7 poistoa
  1. 8 0
      lisp/ChangeLog
  2. 5 0
      lisp/org-compat.el
  3. 3 1
      lisp/org-list.el
  4. 24 6
      lisp/org.el

+ 8 - 0
lisp/ChangeLog

@@ -1,5 +1,13 @@
 2009-02-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-list.el (org-indent-item): Allow point to be at the end of
+	the region.
+
+	* org.el (org-metaleft, org-metaright): Be more accurate about
+	detecting a region where commands apply.
+
+	* org-compat.el (org-cursor-to-region-beginning): New function.
+
 	* org.el (org-priority): Also find invisible heading.
 
 	* org-colview-xemacs.el (org-columns-edit-value): No special

+ 5 - 0
lisp/org-compat.el

@@ -185,6 +185,11 @@ Works on both Emacs and XEmacs."
 	  (use-region-p)
 	(and transient-mark-mode mark-active))))) ; Emacs 22 and before
 
+(defun org-cursor-to-region-beginning ()
+  (when (and (org-region-active-p)
+	     (> (point) (region-beginning)))
+    (exchange-point-and-mark)))
+
 ;; Invisibility compatibility
 
 (defun org-add-to-invisibility-spec (arg)

+ 3 - 1
lisp/org-list.el

@@ -872,17 +872,19 @@ I.e. to the text after the last item."
 (defun org-indent-item (arg)
   "Indent a local list item."
   (interactive "p")
+  (and (org-region-active-p) (org-cursor-to-region-beginning))
   (unless (org-at-item-p)
     (error "Not on an item"))
   (save-excursion
     (let (beg end ind ind1 tmp delta ind-down ind-up)
+      (setq end (and (org-region-active-p) (region-end)))
       (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
 	  (setq beg org-last-indent-begin-marker
 		end org-last-indent-end-marker)
 	(org-beginning-of-item)
 	(setq beg (move-marker org-last-indent-begin-marker (point)))
 	(org-end-of-item)
-	(setq end (move-marker org-last-indent-end-marker (point))))
+	(setq end (move-marker org-last-indent-end-marker (or end (point)))))
       (goto-char beg)
       (setq tmp (org-item-indent-positions)
 	    ind (car tmp)

+ 24 - 6
lisp/org.el

@@ -1328,9 +1328,9 @@ Possible values for the command are:
                does define this command, but you can overrule/replace it
                here.
  string        A command to be executed by a shell; %s will be replaced
-	       by the path to the file.
+               by the path to the file.
  sexp          A Lisp form which will be evaluated.  The file path will
-	       be available in the Lisp variable `file'.
+               be available in the Lisp variable `file'.
 For more examples, see the system specific constants
 `org-file-apps-defaults-macosx'
 `org-file-apps-defaults-windowsnt'
@@ -13458,9 +13458,18 @@ See the individual commands for more information."
   (cond
    ((run-hook-with-args-until-success 'org-metaleft-hook))
    ((org-at-table-p) (org-call-with-arg 'org-table-move-column 'left))
-   ((or (org-on-heading-p) (org-region-active-p))
+   ((or (org-on-heading-p)
+	(and (org-region-active-p)
+	     (save-excursion
+	       (goto-char (region-beginning))
+	       (org-on-heading-p))))
     (call-interactively 'org-do-promote))
-   ((org-at-item-p) (call-interactively 'org-outdent-item))
+   ((or (org-at-item-p)
+	(and (org-region-active-p)
+	     (save-excursion
+	       (goto-char (region-beginning))
+	       (org-at-item-p))))
+    (call-interactively 'org-outdent-item))
    (t (call-interactively 'backward-word))))
 
 (defun org-metaright (&optional arg)
@@ -13472,9 +13481,18 @@ See the individual commands for more information."
   (cond
    ((run-hook-with-args-until-success 'org-metaright-hook))
    ((org-at-table-p) (call-interactively 'org-table-move-column))
-   ((or (org-on-heading-p) (org-region-active-p))
+   ((or (org-on-heading-p)
+	(and (org-region-active-p)
+	     (save-excursion
+	       (goto-char (region-beginning))
+	       (org-on-heading-p))))
     (call-interactively 'org-do-demote))
-   ((org-at-item-p) (call-interactively 'org-indent-item))
+   ((or (org-at-item-p)
+	(and (org-region-active-p)
+	     (save-excursion
+	       (goto-char (region-beginning))
+	       (org-at-item-p))))
+    (call-interactively 'org-indent-item))
    (t (call-interactively 'forward-word))))
 
 (defun org-metaup (&optional arg)