From 56ba0892e5ef136bca03bf53eb7ca8d1c45b7d88 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 21 Apr 2010 08:38:09 +0200 Subject: [PATCH 1/5] Simplify XEmacs key bindings --- lisp/ChangeLog | 9 +++++++++ lisp/org-agenda.el | 6 ++---- lisp/org-compat.el | 9 +++++++++ lisp/org-mouse.el | 30 ++++++++++++++---------------- lisp/org.el | 32 +++++++++++++++----------------- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5890329e1..57ddae3eb 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2010-04-21 Carsten Dominik + + * org.el (org-key): Apply the translations defined in + `org-xemacs-key-equivalents'. + + * org-mouse.el (org-mode-hook): Use `org-defkey'. + + * org-compat.el (org-xemacs-key-equivalents): New constant. + 2010-04-20 Carsten Dominik * org-inlinetask.el (org-inlinetask-defaut-state): New option. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index e602747d4..9dd7d19db 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1662,10 +1662,8 @@ The following commands are available: (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull) (org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push) -(org-defkey org-agenda-mode-map - (if (featurep 'xemacs) [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse) -(org-defkey org-agenda-mode-map - (if (featurep 'xemacs) [(button3)] [(mouse-3)]) 'org-agenda-show-mouse) +(org-defkey org-agenda-mode-map [mouse-2] 'org-agenda-goto-mouse) +(org-defkey org-agenda-mode-map [mouse-3] 'org-agenda-show-mouse) (when org-agenda-mouse-1-follows-link (org-defkey org-agenda-mode-map [follow-link] 'mouse-face)) (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu" diff --git a/lisp/org-compat.el b/lisp/org-compat.el index b5987d597..b6c7b6185 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -88,6 +88,15 @@ any other entries, and any resulting duplicates will be removed entirely." ;;;; Emacs/XEmacs compatibility +;; Keys +(defconst org-xemacs-key-equivalents + '(([mouse-1] . [button1]) + ([mouse-2] . [button2]) + ([mouse-3] . [button3]) + ([C-mouse-4] . [(control mouse-4)]) + ([C-mouse-5] . [(control mouse-5)])) + "Translation alist for a couple of keys") + ;; Overlay compatibility functions (defun org-detach-overlay (ovl) (if (featurep 'xemacs) (detach-extent ovl) (delete-overlay ovl))) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 2d68b1a53..af127235f 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -909,18 +909,18 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (setq org-mouse-context-menu-function 'org-mouse-context-menu) (when (memq 'context-menu org-mouse-features) - (define-key org-mouse-map (if (featurep 'xemacs) [button3] [mouse-3]) nil) - (define-key org-mode-map [mouse-3] 'org-mouse-show-context-menu)) - (define-key org-mode-map [down-mouse-1] 'org-mouse-down-mouse) + (org-defkey org-mouse-map [mouse-3] nil) + (org-defkey org-mode-map [mouse-3] 'org-mouse-show-context-menu)) + (org-defkey org-mode-map [down-mouse-1] 'org-mouse-down-mouse) (when (memq 'context-menu org-mouse-features) - (define-key org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree) - (define-key org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start)) + (org-defkey org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree) + (org-defkey org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start)) (when (memq 'yank-link org-mouse-features) - (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link) - (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link)) + (org-defkey org-mode-map [S-mouse-2] 'org-mouse-yank-link) + (org-defkey org-mode-map [drag-mouse-3] 'org-mouse-yank-link)) (when (memq 'move-tree org-mouse-features) - (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree) - (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start)) + (org-defkey org-mouse-map [drag-mouse-3] 'org-mouse-move-tree) + (org-defkey org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start)) (when (memq 'activate-stars org-mouse-features) (font-lock-add-keywords @@ -1131,13 +1131,11 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (add-hook 'org-agenda-mode-hook '(lambda () (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu) - (define-key org-agenda-mode-map - (if (featurep 'xemacs) [button3] [mouse-3]) - 'org-mouse-show-context-menu) - (define-key org-agenda-mode-map [down-mouse-3] 'org-mouse-move-tree-start) - (define-key org-agenda-mode-map (if (featurep 'xemacs) [(control mouse-4)] [C-mouse-4]) 'org-agenda-earlier) - (define-key org-agenda-mode-map (if (featurep 'xemacs) [(control mouse-5)] [C-mouse-5]) 'org-agenda-later) - (define-key org-agenda-mode-map [drag-mouse-3] + (org-defkey org-agenda-mode-map [mouse-3] 'org-mouse-show-context-menu) + (org-defkey org-agenda-mode-map [down-mouse-3] 'org-mouse-move-tree-start) + (org-defkey org-agenda-mode-map [C-mouse-4] 'org-agenda-earlier) + (org-defkey org-agenda-mode-map [C-mouse-5] 'org-agenda-later) + (org-defkey org-agenda-mode-map [drag-mouse-3] '(lambda (event) (interactive "e") (case (org-mouse-get-gesture event) (:left (org-agenda-earlier 1)) diff --git a/lisp/org.el b/lisp/org.el index b843664eb..eb16a4d25 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -417,14 +417,17 @@ therefore you'll have to restart Emacs to apply it after changing." (defun org-key (key) "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'. -Or return the original if not disputed." - (if org-replace-disputed-keys - (let* ((nkey (key-description key)) - (x (org-find-if (lambda (x) - (equal (key-description (car x)) nkey)) - org-disputed-keys))) - (if x (cdr x) key)) - key)) +Or return the original if not disputed. +Also apply the trnaslations defined in `org-xemacs-key-equivalents'." + (when org-replace-disputed-keys + (let* ((nkey (key-description key)) + (x (org-find-if (lambda (x) + (equal (key-description (car x)) nkey)) + org-disputed-keys))) + (setq key (if x (cdr x) key)))) + (when (featurep 'xemacs) + (setq key (or (cdr (assoc key org-xemacs-key-equivalents)) key))) + key) (defun org-find-if (predicate seq) (catch 'exit @@ -4480,10 +4483,8 @@ The following commands are available: ;;;; Font-Lock stuff, including the activators (defvar org-mouse-map (make-sparse-keymap)) -(org-defkey org-mouse-map - (if (featurep 'xemacs) [button2] [mouse-2]) 'org-open-at-mouse) -(org-defkey org-mouse-map - (if (featurep 'xemacs) [button3] [mouse-3]) 'org-find-file-at-mouse) +(org-defkey org-mouse-map [mouse-2] 'org-open-at-mouse) +(org-defkey org-mouse-map [mouse-3] 'org-find-file-at-mouse) (when org-mouse-1-follows-link (org-defkey org-mouse-map [follow-link] 'mouse-face)) (when org-tab-follows-link @@ -5481,7 +5482,6 @@ in special contexts. (while (and (not (eobp)) ;; this is like `next-line' (get-char-property (1- (point)) 'invisible)) (goto-char (next-single-char-property-change (point) 'invisible)) -;;;??? (or (bolp) (beginning-of-line 2)))) (and (eolp) (beginning-of-line 2)))) (setq eol (point))) (outline-end-of-heading) (setq eoh (point)) @@ -13589,10 +13589,8 @@ user." (map (copy-keymap calendar-mode-map)) (minibuffer-local-map (copy-keymap minibuffer-local-map))) (org-defkey map (kbd "RET") 'org-calendar-select) - (org-defkey map (if (featurep 'xemacs) [button1] [mouse-1]) - 'org-calendar-select-mouse) - (org-defkey map (if (featurep 'xemacs) [button2] [mouse-2]) - 'org-calendar-select-mouse) + (org-defkey map [mouse-1] 'org-calendar-select-mouse) + (org-defkey map [mouse-2] 'org-calendar-select-mouse) (org-defkey minibuffer-local-map [(meta shift left)] (lambda () (interactive) (org-eval-in-calendar '(calendar-backward-month 1)))) From e0ca9a5bdf0dc61e3c117891b3b6b3f8dc6bc4fd Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 21 Apr 2010 09:03:30 +0200 Subject: [PATCH 2/5] More work on simplifying compatibility code --- lisp/ChangeLog | 8 ++++++++ lisp/org-agenda.el | 5 ++--- lisp/org-clock.el | 11 +++++------ lisp/org-colview.el | 3 +++ lisp/org.el | 6 ++---- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 57ddae3eb..31d7f6432 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,13 @@ 2010-04-21 Carsten Dominik + * org-colview-xemacs.el: Make sure this file is never loaded into + Emacs. Remove all tests for XEmacs. + + * org-colview.el: Make sure this file is never loaded into XEmacs. + + * org-agenda.el (org-highlight, org-unhighlight): Use direct + overlay calls. + * org.el (org-key): Apply the translations defined in `org-xemacs-key-equivalents'. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 9dd7d19db..c68038da3 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5878,12 +5878,11 @@ so that the date SD will be in that range." (defun org-highlight (begin end &optional buffer) "Highlight a region with overlay." - (funcall (if (featurep 'xemacs) 'set-extent-endpoints 'move-overlay) - org-hl begin end (or buffer (current-buffer)))) + (move-overlay org-hl begin end (or buffer (current-buffer)))) (defun org-unhighlight () "Detach overlay INDEX." - (funcall (if (featurep 'xemacs) 'detach-extent 'delete-overlay) org-hl)) + (org-detach-overlay org-hl)) ;; FIXME this is currently not used. (defun org-highlight-until-next-command (beg end &optional buffer) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index b971a75a7..d1805e66d 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -759,11 +759,10 @@ was started." (goto-char (match-end 0))) nil)))))) (let (char-pressed) - (if (featurep 'xemacs) - (progn - (message (concat (funcall prompt-fn clock) - " [(kK)eep (sS)ubtract (C)ancel]? ")) - (setq char-pressed (read-char-exclusive))) + (when (featurep 'xemacs) + (message (concat (funcall prompt-fn clock) + " [(kK)eep (sS)ubtract (C)ancel]? ")) + (setq char-pressed (read-char-exclusive))) (while (or (null char-pressed) (and (not (memq char-pressed '(?k ?K ?s ?S ?C ?i))) (or (ding) t))) @@ -771,7 +770,7 @@ was started." (read-char (concat (funcall prompt-fn clock) " [(kK)p (sS)ub (C)ncl (i)gn]? ") nil 45))) - (and (not (eq char-pressed ?i)) char-pressed)))))) + (and (not (eq char-pressed ?i)) char-pressed))))) (default (floor (/ (org-float-time (time-subtract (current-time) last-valid)) 60))) (keep (and (memq ch '(?k ?K)) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 6cb701005..f80c91221 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -36,6 +36,9 @@ (declare-function org-agenda-redo "org-agenda" ()) (declare-function org-agenda-do-context-action "org-agenda" ()) +(when (featurep 'xemacs) + (error "Do not load this file into XEmacs, use 'org-colview-xemacs.el'.")) + ;;; Column View (defvar org-columns-overlays nil diff --git a/lisp/org.el b/lisp/org.el index eb16a4d25..0eaf326c2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4356,7 +4356,7 @@ The following commands are available: ;; we switch another buffer into org-mode. (if (featurep 'xemacs) (when (boundp 'outline-mode-menu-heading) - ;; Assume this is Greg's port, it used easymenu + ;; Assume this is Greg's port, it uses easymenu (easy-menu-remove outline-mode-menu-heading) (easy-menu-remove outline-mode-menu-show) (easy-menu-remove outline-mode-menu-hide)) @@ -16999,9 +16999,7 @@ With prefix arg UNCOMPILED, load the uncompiled versions." "Display the given MESSAGE as a warning." (if (fboundp 'display-warning) (display-warning 'org message - (if (featurep 'xemacs) - 'warning - :warning)) + (if (featurep 'xemacs) 'warning :warning)) (let ((buf (get-buffer-create "*Org warnings*"))) (with-current-buffer buf (goto-char (point-max)) From 75a68313fcec1b5977269a5c0fe6b857b62398f2 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 21 Apr 2010 09:10:57 +0200 Subject: [PATCH 3/5] Fix typo --- lisp/org-inlinetask.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index 9479aea69..df1c48d46 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -110,9 +110,9 @@ When nil, they will not be exported." This should be the state `org-inlinetask-insert-task' should use by default, or nil of no state should be assigned." :group 'org-inlinetask - :type (choice - (const :tag "No state" nil) - (string :tag "Specific state"))) + :type '(choice + (const :tag "No state" nil) + (string :tag "Specific state"))) (defun org-inlinetask-insert-task (&optional no-state) "Insert an inline task. From 008dbe15ec2d6c66249d345ca7394bac89a96bd7 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 21 Apr 2010 09:49:31 +0200 Subject: [PATCH 4/5] Don't mistake ditaa figures for tables Patch by Dan Davison, after a report by Bernt Hansen. --- lisp/ChangeLog | 3 +++ lisp/org-src.el | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 31d7f6432..13bebac3a 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-04-21 Carsten Dominik + * org-src.el (org-edit-src-find-region-and-lang): Test for + table.el as late as possible. + * org-colview-xemacs.el: Make sure this file is never loaded into Emacs. Remove all tests for XEmacs. diff --git a/lisp/org-src.el b/lisp/org-src.el index 14fb40278..8eab12aaf 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -459,15 +459,6 @@ the language, a switch telling if the content should be in a single line." (pos (point)) re1 re2 single beg end lang lfmt match-re1 ind entry) (catch 'exit - (when (org-at-table.el-p) - (re-search-backward "^[\t]*[^ \t|\\+]" nil t) - (setq beg (1+ (point-at-eol))) - (goto-char beg) - (or (re-search-forward "^[\t]*[^ \t|\\+]" nil t) - (progn (goto-char (point-max)) (newline))) - (setq end (point-at-bol)) - (setq ind (org-edit-src-get-indentation beg)) - (throw 'exit (list beg end 'table.el nil nil ind))) (while (setq entry (pop re-list)) (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry) single (nth 3 entry)) @@ -498,7 +489,16 @@ the language, a switch telling if the content should be in a single line." (throw 'exit (list (match-end 0) end (org-edit-src-get-lang lang) - single lfmt ind)))))))))))) + single lfmt ind))))))))) + (when (org-at-table.el-p) + (re-search-backward "^[\t]*[^ \t|\\+]" nil t) + (setq beg (1+ (point-at-eol))) + (goto-char beg) + (or (re-search-forward "^[\t]*[^ \t|\\+]" nil t) + (progn (goto-char (point-max)) (newline))) + (setq end (point-at-bol)) + (setq ind (org-edit-src-get-indentation beg)) + (throw 'exit (list beg end 'table.el nil nil ind)))))) (defun org-edit-src-get-lang (lang) "Extract the src language." From e84998ada85419921fdc68c0d9950918ccb25ad0 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 21 Apr 2010 09:51:30 +0200 Subject: [PATCH 5/5] Fix typo --- lisp/org-list.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-list.el b/lisp/org-list.el index d3bfb6bf4..79c939c22 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -119,7 +119,7 @@ When a string, it will be used as a regular expression. When the bullet type of a list is changed, the new bullet type will be matched against this regexp. If it matches, there will be two spaces instead of one after the bullet in each item of he list." - :group 'org-plain-list + :group 'org-plain-lists :type '(choice (const :tag "never" nil) (regexp)))