Browse Source

org.el: Introduce a tiny syntax table for a new function `org-transpose-words'

* org.el (org-syntax-table): New variable.
(org-transpose-words): New command, simply wrapping the new
syntax table around `transpose-words'.
(org-mode-map): Bind `org-transpose-words' to `M-t'.

Thanks to Eric Abrahamsen for this idea.
Bastien Guerry 13 years ago
parent
commit
0f7500704e
1 changed files with 14 additions and 0 deletions
  1. 14 0
      lisp/org.el

+ 14 - 0
lisp/org.el

@@ -3882,6 +3882,13 @@ Use customize to modify this, or restart Emacs after changing it."
 	   (string :tag "HTML end tag")
 	   (string :tag "HTML end tag")
 	   (option (const verbatim)))))
 	   (option (const verbatim)))))
 
 
+(defvar org-syntax-table
+  (let ((st (make-syntax-table)))
+    (mapc (lambda(c) (modify-syntax-entry
+		      (string-to-char (car c)) "w p" st))
+	  org-emphasis-alist)
+    st))
+
 (defvar org-protecting-blocks
 (defvar org-protecting-blocks
   '("src" "example" "latex" "ascii" "html" "docbook" "ditaa" "dot" "r" "R")
   '("src" "example" "latex" "ascii" "html" "docbook" "ditaa" "dot" "r" "R")
   "Blocks that contain text that is quoted, i.e. not processed as Org syntax.
   "Blocks that contain text that is quoted, i.e. not processed as Org syntax.
@@ -18287,6 +18294,7 @@ BEG and END default to the buffer boundaries."
     (org-defkey narrow-map "e" 'org-narrow-to-element)
     (org-defkey narrow-map "e" 'org-narrow-to-element)
   (org-defkey org-mode-map "\C-xne" 'org-narrow-to-element))
   (org-defkey org-mode-map "\C-xne" 'org-narrow-to-element))
 (org-defkey org-mode-map "\C-\M-t"  'org-transpose-element)
 (org-defkey org-mode-map "\C-\M-t"  'org-transpose-element)
+(org-defkey org-mode-map "\M-t"  'org-transpose-words)
 (org-defkey org-mode-map "\M-}"     'org-forward-element)
 (org-defkey org-mode-map "\M-}"     'org-forward-element)
 (org-defkey org-mode-map "\M-{"     'org-backward-element)
 (org-defkey org-mode-map "\M-{"     'org-backward-element)
 (org-defkey org-mode-map "\C-c\C-^" 'org-up-element)
 (org-defkey org-mode-map "\C-c\C-^" 'org-up-element)
@@ -22513,6 +22521,12 @@ ones already marked."
        (org-element-property :begin elem)
        (org-element-property :begin elem)
        (org-element-property :end elem))))))
        (org-element-property :end elem))))))
 
 
+(defun org-transpose-words ()
+  "Transpose words, using `org-mode' syntax table."
+  (interactive)
+  (with-syntax-table org-syntax-table
+    (call-interactively 'transpose-words)))
+
 (defun org-transpose-element ()
 (defun org-transpose-element ()
   "Transpose current and previous elements, keeping blank lines between.
   "Transpose current and previous elements, keeping blank lines between.
 Point is moved after both elements."
 Point is moved after both elements."