annotate lisp/textmodes/org-mouse.el @ 92488:62faea4a9ef4

(gnus-article-mode-line-format-alist): Move to gnus-sum.
author Glenn Morris <rgm@gnu.org>
date Wed, 05 Mar 2008 03:56:16 +0000
parents 50aec4a9ce08
children 9d0bccd6c171
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
87831
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-mouse.el --- Better mouse support for org-mode
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2
87841
f76850f6a776 Remove copyright from author with assignment, merge years into FSF
Glenn Morris <rgm@gnu.org>
parents: 87831
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation
87831
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7 ;; Version: 5.19
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14 ;; any later version.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; GNU General Public License for more details.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 ;;; Commentary:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;; Org-mouse provides mouse support for org-mode.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;; http://orgmode.org
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;; Org-mouse implements the following features:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 ;; * following links with the left mouse button (in Emacs 22)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 ;; * subtree expansion/collapse (org-cycle) with the left mouse button
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;; * several context menus on the right mouse button:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 ;; + general text
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; + headlines
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;; + timestamps
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 ;; + priorities
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;; + links
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 ;; + tags
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;; * promoting/demoting/moving subtrees with mouse-3
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; + if the drag starts and ends in the same line then promote/demote
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 ;; + otherwise move the subtree
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;; Use
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; ---
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 ;; To use this package, put the following line in your .emacs:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;; (require 'org-mouse)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 ;; Fixme:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;; + deal with folding / unfolding issues
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 ;; TODO (This list is only theoretical, if you'd like to have some
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;; feature implemented or a bug fix please send me an email, even if
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 ;; something similar appears in the list below. This will help me get
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;; the priorities right.):
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 ;; + org-store-link, insert link
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 ;; + org tables
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 ;; + occur with the current word/tag (same menu item)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 ;; + ctrl-c ctrl-c, for example, renumber the current list
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 ;; + internal links
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 ;; Please email the maintainer with new feature suggestions / bugs
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 ;; History:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 ;; SInce version 5.10: Changes are listed in the general org-mode docs.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 ;; Version 5.09
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 ;; + Version number synchronization with Org-mode.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 ;; Version 0.25
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 ;; + made compatible with org-mode 4.70 (thanks to Carsten for the patch)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 ;; Version 0.24
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 ;; + minor changes to the table menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 ;; Version 0.23
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 ;; + preliminary support for tables and calculation marks
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 ;; + context menu support for org-agenda-undo & org-sort-entries
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 ;; Version 0.22
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 ;; + handles undo support for the agenda buffer (requires org-mode >=4.58)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 ;; Version 0.21
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;; + selected text activates its context menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 ;; + shift-middleclick or right-drag inserts the text from the clipboard in the form of a link
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 ;; Version 0.20
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 ;; + the new "TODO Status" submenu replaces the "Cycle TODO" menu item
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 ;; + the TODO menu can now list occurrences of a specific TODO keyword
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 ;; + #+STARTUP line is now recognized
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 ;; Version 0.19
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 ;; + added support for dragging URLs to the org-buffer
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 ;; Version 0.18
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 ;; + added support for agenda blocks
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;; Version 0.17
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 ;; + toggle checkboxes with a single click
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 ;; Version 0.16
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 ;; + added support for checkboxes
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 ;; Version 0.15
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 ;; + org-mode now works with the Agenda buffer as well
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 ;; Version 0.14
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 ;; + added a menu option that converts plain list items to outline items
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 ;; Version 0.13
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 ;; + "Insert Heading" now inserts a sibling heading if the point is
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 ;; on "***" and a child heading otherwise
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 ;; Version 0.12
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 ;; + compatible with Emacs 21
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 ;; + custom agenda commands added to the main menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 ;; + moving trees should now work between windows in the same frame
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 ;; Version 0.11
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 ;; + fixed org-mouse-at-link (thanks to Carsten)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 ;; + removed [follow-link] bindings
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 ;; Version 0.10
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 ;; + added a menu option to remove highlights
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 ;; + compatible with org-mode 4.21 now
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 ;; Version 0.08:
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 ;; + trees can be moved/promoted/demoted by dragging with the right
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 ;; mouse button (mouse-3)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 ;; + small changes in the above function
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 ;;
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 ;; Versions 0.01 -- 0.07: (I don't remember)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (eval-when-compile (require 'cl))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 (require 'org)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 "Regular expression that matches a plain list.")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 (defvar org-mouse-direct t
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148 "Internal variable indicating whether the current action is direct.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 If t, then the current action has been invoked directly through the buffer
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 it is intended to operate on. If nil, then the action has been invoked
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 indirectly, for example, through the agenda buffer.")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 (defgroup org-mouse nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 "Mouse support for org-mode."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 :tag "Org Mouse"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 :group 'org)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 (defcustom org-mouse-punctuation ":"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 "Punctuation used when inserting text by drag and drop."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 :group 'org-mouse
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 :type 'string)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 (defun org-mouse-re-search-line (regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 "Search the current line for a given regular expression."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 (beginning-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (re-search-forward regexp (point-at-eol) t))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 (defun org-mouse-end-headline ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 "Go to the end of current headline (ignoring tags)."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 (end-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 (skip-chars-backward "\t ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 (when (looking-back ":[A-Za-z]+:")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176 (skip-chars-backward ":A-Za-z")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 (skip-chars-backward "\t ")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 (defvar org-mouse-context-menu-function nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 "Function to create the context menu.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 The value of this variable is the function invoked by
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 `org-mouse-context-menu' as the context menu.")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 (make-variable-buffer-local 'org-mouse-context-menu-function)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (defun org-mouse-show-context-menu (event prefix)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 "Invoke the context menu.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 If the value of `org-mouse-context-menu-function' is a function, then
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 this function is called. Otherwise, the current major mode menu is used."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (interactive "@e \nP")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 (if (and (= (event-click-count event) 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (or (not mark-active)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 (sit-for (/ double-click-time 1000.0))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (progn
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 (select-window (posn-window (event-start event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196 (when (not (org-mouse-mark-active))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (goto-char (posn-point (event-start event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 (when (not (eolp)) (save-excursion (run-hooks 'post-command-hook)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 (let ((redisplay-dont-pause t))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 (sit-for 0)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 (if (functionp org-mouse-context-menu-function)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (funcall org-mouse-context-menu-function event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 (mouse-major-mode-menu event prefix)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 (setq this-command 'mouse-save-then-kill)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 (mouse-save-then-kill event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 (defun org-mouse-line-position ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 "Returns `:beginning' or `:middle' or `:end', depending on the point position.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 If the point is at the end of the line, return `:end'.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 If the point is separated from the beginning of the line only by white
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 space and *'s (`org-mouse-bolp'), return `:beginning'. Otherwise,
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 return `:middle'."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 (cond
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 ((eolp) :end)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 ((org-mouse-bolp) :beginning)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 (t :middle)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 (defun org-mouse-empty-line ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 "Return non-nil iff the line contains only white space."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 (save-excursion (beginning-of-line) (looking-at "[ \t]*$")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 (defun org-mouse-next-heading ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 "Go to the next heading.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 If there is none, ensure that the point is at the beginning of an empty line."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227 (unless (outline-next-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 (beginning-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 (unless (org-mouse-empty-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 (end-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 (newline))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 (defun org-mouse-insert-heading ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 "Insert a new heading, as `org-insert-heading'.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236 If the point is at the :beginning (`org-mouse-line-position') of the line,
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 insert the new heading before the current line. Otherwise, insert it
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 after the current heading."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 (case (org-mouse-line-position)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 (:beginning (beginning-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 (org-insert-heading))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 (t (org-mouse-next-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 (org-insert-heading))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 (defun org-mouse-timestamp-today (&optional shift units)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 "Change the timestamp into SHIFT UNITS in the future.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249 For the acceptable UNITS, see `org-timestamp-change'."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251 (flet ((org-read-date (&rest rest) (current-time)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 (org-time-stamp nil))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 (when shift
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 (org-timestamp-change shift units)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 (defun org-mouse-keyword-menu (keywords function &optional selected itemformat)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 "A helper function.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 Returns a menu fragment consisting of KEYWORDS. When a keyword
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 is selected by the user, FUNCTION is called with the selected
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 keyword as the only argument.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 If SELECTED is nil, then all items are normal menu items. If
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 SELECTED is a function, then each item is a checkbox, which is
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265 enabled for a given keyword iff (funcall SELECTED keyword) return
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266 non-nil. If SELECTED is neither nil nor a function, then the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 items are radio buttons. A radio button is enabled for the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 keyword `equal' to SELECTED.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 ITEMFORMAT governs formatting of the elements of KEYWORDS. If it
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 is a function, it is invoked with the keyword as the only
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 argument. If it is a string, it is interpreted as the format
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 string to (format ITEMFORMAT keyword). If it is neither a string
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 nor a function, elements of KEYWORDS are used directly. "
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 (mapcar
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 `(lambda (keyword)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 (vector (cond
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 ((functionp ,itemformat) (funcall ,itemformat keyword))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 ((stringp ,itemformat) (format ,itemformat keyword))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 (t keyword))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 (list 'funcall ,function keyword)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 :style (cond
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 ((null ,selected) t)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 ((functionp ,selected) 'toggle)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 (t 'radio))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 :selected (if (functionp ,selected)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 (and (funcall ,selected keyword) t)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 (equal ,selected keyword))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 keywords))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 (defun org-mouse-remove-match-and-spaces ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 "Remove the match, make just one space around the point."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (replace-match "")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 (just-one-space))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (defvar rest)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 (defun org-mouse-replace-match-and-surround (newtext &optional fixedcase
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 literal string subexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 "The same as `replace-match', but surrounds the replacement with spaces."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301 (apply 'replace-match rest)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 (goto-char (match-beginning (or subexp 0)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 (just-one-space)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305 (goto-char (match-end (or subexp 0)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 (just-one-space)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 (defun org-mouse-keyword-replace-menu (keywords &optional group itemformat
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 nosurround)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 "A helper function.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313 Returns a menu fragment consisting of KEYWORDS. When a keyword
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 is selected, group GROUP of the current match is replaced by the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 keyword. The method ensures that both ends of the replacement
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 are separated from the rest of the text in the buffer by
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
317 individual spaces (unless NOSURROND is non-nil).
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
318
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
319 The final entry of the menu is always \"None\", which removes the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
320 match.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
321
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
322 ITEMFORMAT governs formatting of the elements of KEYWORDS. If it
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 is a function, it is invoked with the keyword as the only
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 argument. If it is a string, it is interpreted as the format
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 string to (format ITEMFORMAT keyword). If it is neither a string
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326 nor a function, elements of KEYWORDS are used directly.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327 "
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 (setq group (or group 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 (let ((replace (org-mouse-match-closure
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 (if nosurround 'replace-match
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331 'org-mouse-replace-match-and-surround))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 (append
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 (org-mouse-keyword-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 keywords
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 `(lambda (keyword) (funcall ,replace keyword t t nil ,group))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336 (match-string group)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 itemformat)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 `(["None" org-mouse-remove-match-and-spaces
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 :style radio
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 :selected ,(not (member (match-string group) keywords))]))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 (defun org-mouse-show-headlines ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 "Change the visibility of the current org buffer to only show headlines."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 (let ((this-command 'org-cycle)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346 (last-command 'org-cycle)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347 (org-cycle-global-status nil))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 (org-cycle '(4))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349 (org-cycle '(4))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351 (defun org-mouse-show-overview ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 "Change visibility of current org buffer to first-level headlines only."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354 (let ((org-cycle-global-status nil))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
355 (org-cycle '(4))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
356
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357 (defun org-mouse-set-priority (priority)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
358 "Set the priority of the current headline to PRIORITY."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 (flet ((read-char-exclusive () priority))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 (org-priority)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 (defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 "Regular expression matching the priority indicator.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 Differs from `org-priority-regexp' in that it doesn't contain the
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 leading '.*?'.")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367 (defun org-mouse-get-priority (&optional default)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 "Return the priority of the current headline.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 DEFAULT is returned if no priority is given in the headline."
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 (if (org-mouse-re-search-line org-mouse-priority-regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 (match-string 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373 (when default (char-to-string org-default-priority)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 ;; (defun org-mouse-at-link ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 ;; (and (eq (get-text-property (point) 'face) 'org-link)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 ;; (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 ;; (goto-char (previous-single-property-change (point) 'face))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 ;; (or (looking-at org-bracket-link-regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 ;; (looking-at org-angle-link-re)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 ;; (looking-at org-plain-link-re)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 (defun org-mouse-delete-timestamp ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 "Deletes the current timestamp as well as the preceding keyword.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 (when (or (org-at-date-range-p) (org-at-timestamp-p))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 (replace-match "") ; delete the timestamp
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 (skip-chars-backward " :A-Z")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 (when (looking-at " *[A-Z][A-Z]+:")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 (replace-match ""))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (defun org-mouse-looking-at (regexp skipchars &optional movechars)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 (let ((point (point)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396 (if (looking-at regexp) t
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 (skip-chars-backward skipchars)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 (forward-char (or movechars 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 (when (looking-at regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 (> (match-end 0) point))))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 (defun org-mouse-priority-list ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 (loop for priority from ?A to org-lowest-priority
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 collect (char-to-string priority)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 (defun org-mouse-tag-menu () ;todo
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 (append
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 (let ((tags (org-split-string (org-get-tags) ":")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 (org-mouse-keyword-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411 `(lambda (tag)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412 (org-mouse-set-tags
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413 (sort (if (member tag (quote ,tags))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 (delete tag (quote ,tags))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 (cons tag (quote ,tags)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416 'string-lessp)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 `(lambda (tag) (member tag (quote ,tags)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 ))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419 '("--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 ["Align Tags Here" (org-set-tags nil t) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 ["Align Tags in Buffer" (org-set-tags t t) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 ["Set Tags ..." (org-set-tags) t])))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 (defun org-mouse-set-tags (tags)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 ;; remove existing tags first
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 (beginning-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 (when (org-mouse-re-search-line ":\\(\\([A-Za-z_]+:\\)+\\)")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 (replace-match ""))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 ;; set new tags if any
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 (when tags
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435 (end-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 (insert " :" (mapconcat 'identity tags ":") ":")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 (org-set-tags nil t))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 (defun org-mouse-insert-checkbox ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441 (and (org-at-item-p)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 (goto-char (match-end 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 (unless (org-at-item-checkbox-p)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 (delete-horizontal-space)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 (insert " [ ] "))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 (defun org-mouse-agenda-type (type)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 (case type
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 ('tags "Tags: ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 ('todo "TODO: ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 ('tags-tree "Tags tree: ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 ('todo-tree "TODO tree: ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 ('occur-tree "Occur tree: ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 (t "Agenda command ???")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
457 (defun org-mouse-list-options-menu (alloptions &optional function)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
458 (let ((options (save-match-data
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
459 (split-string (match-string-no-properties 1)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
460 (print options)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 (loop for name in alloptions
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
462 collect
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 (vector name
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
464 `(progn
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
465 (replace-match
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
466 (mapconcat 'identity
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
467 (sort (if (member ',name ',options)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468 (delete ',name ',options)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 (cons ',name ',options))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 'string-lessp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471 " ")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
472 nil nil nil 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
473 (when (functionp ',function) (funcall ',function)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 :style 'toggle
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 :selected (and (member name options) t)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 (defun org-mouse-clip-text (text maxlength)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 (if (> (length text) maxlength)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 (concat (substring text 0 (- maxlength 3)) "...")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 text))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 (defun org-mouse-popup-global-menu ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 `("Main Menu"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 ["Show Overview" org-mouse-show-overview t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 ["Show Headlines" org-mouse-show-headlines t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487 ["Show All" show-all t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 ["Remove Highlights" org-remove-occur-highlights
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489 :visible org-occur-highlights]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 ["Check Deadlines"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 (if (functionp 'org-check-deadlines-and-todos)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 (org-check-deadlines-and-todos org-deadline-warning-days)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 (org-check-deadlines org-deadline-warning-days)) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 ["Check TODOs" org-show-todo-tree t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 ("Check Tags"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 ,@(org-mouse-keyword-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 '(lambda (tag) (org-tags-sparse-tree nil tag)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 ["Custom Tag ..." org-tags-sparse-tree t])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 ["Check Phrase ..." org-occur]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 ["Display Agenda" org-agenda-list t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 ["Display Timeline" org-timeline t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 ["Display TODO List" org-todo-list t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507 ("Display Tags"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508 ,@(org-mouse-keyword-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 '(lambda (tag) (org-tags-view nil tag)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 ["Custom Tag ..." org-tags-view t])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 ["Display Calendar" org-goto-calendar t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515 ,@(org-mouse-keyword-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (mapcar 'car org-agenda-custom-commands)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 '(lambda (key)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 (eval `(flet ((read-char-exclusive () (string-to-char ,key)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 (org-agenda nil))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 '(lambda (key)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 (let ((entry (assoc key org-agenda-custom-commands)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 (org-mouse-clip-text
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 (cond
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 ((stringp (nth 1 entry)) (nth 1 entry))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 ((stringp (nth 2 entry))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 (concat (org-mouse-agenda-type (nth 1 entry))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 (nth 2 entry)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 (t "Agenda Command '%s'"))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 30))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 ["Delete Blank Lines" delete-blank-lines
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 :visible (org-mouse-empty-line)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 ["Insert Checkbox" org-mouse-insert-checkbox
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536 ["Insert Checkboxes"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 (org-mouse-for-each-item 'org-mouse-insert-checkbox)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 ["Plain List to Outline" org-mouse-transform-to-outline
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 :visible (org-at-item-p)])))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543 (defun org-mouse-get-context (contextlist context)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 (let ((contextdata (assq context contextlist)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 (when contextdata
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 (goto-char (second contextdata))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 (re-search-forward ".*" (third contextdata))))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 (defun org-mouse-for-each-item (function)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 (ignore-errors
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (while t (org-previous-item)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 (ignore-errors
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 (while t
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 (funcall function)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (org-next-item)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 (defun org-mouse-bolp ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 "Returns true if there only spaces, tabs, and '*', between the beginning of line and the point"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 (skip-chars-backward " \t*") (bolp)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 (defun org-mouse-insert-item (text)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 (case (org-mouse-line-position)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 (:beginning ; insert before
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 (beginning-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 (looking-at "[ \t]*")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (open-line 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 (indent-to (- (match-end 0) (match-beginning 0)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 (insert "+ "))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 (:middle ; insert after
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 (end-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 (newline t)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 (indent-relative)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 (insert "+ "))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579 (:end ; insert text here
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (skip-chars-backward " \t")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 (kill-region (point) (point-at-eol))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 (unless (looking-back org-mouse-punctuation)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583 (insert (concat org-mouse-punctuation " ")))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 (insert text)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 (beginning-of-line))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 (defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 (if (eq major-mode 'org-mode)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 (org-mouse-insert-item text)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 ad-do-it))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (defadvice dnd-open-file (around org-mouse-dnd-open-file activate)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 (if (eq major-mode 'org-mode)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 (org-mouse-insert-item uri)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596 ad-do-it))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 (defun org-mouse-match-closure (function)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 (let ((match (match-data t)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 `(lambda (&rest rest)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601 (save-match-data
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (set-match-data ',match)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 (apply ',function rest)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 (defun org-mouse-todo-keywords ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 (if (boundp 'org-todo-keywords-1) org-todo-keywords-1 org-todo-keywords))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608 (defun org-mouse-match-todo-keyword ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 (org-back-to-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 (if (looking-at outline-regexp) (goto-char (match-end 0)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 (or (looking-at (concat " +" org-todo-regexp " *"))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (looking-at " \\( *\\)"))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 (defun org-mouse-yank-link (click)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 (interactive "e")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 ;; Give temporary modes such as isearch a chance to turn off.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 (run-hooks 'mouse-leave-buffer-hook)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 (mouse-set-point click)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620 (setq mouse-selection-click-count 0)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 (delete-horizontal-space)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622 (insert-for-yank (concat " [[" (current-kill 0) "]] ")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 (defun org-mouse-context-menu (&optional event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 (let ((stamp-prefixes (list org-deadline-string org-scheduled-string))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 (contextlist (org-context)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 (flet ((get-context (context) (org-mouse-get-context contextlist context)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 (cond
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629 ((org-mouse-mark-active)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630 (let ((region-string (buffer-substring (region-beginning) (region-end))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
631 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
632 `(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
633 ["Sparse Tree" (org-occur ',region-string)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634 ["Find in Buffer" (occur ',region-string)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635 ["Grep in Current Dir"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 (grep (format "grep -rnH -e '%s' *" ',region-string))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 ["Grep in Parent Dir"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
638 (grep (format "grep -rnH -e '%s' ../*" ',region-string))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 ["Convert to Link"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 (progn (save-excursion (goto-char (region-beginning)) (insert "[["))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 (save-excursion (goto-char (region-end)) (insert "]]")))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 ["Insert Link Here" (org-mouse-yank-link ',event)]))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 ((save-excursion (beginning-of-line) (looking-at "#\\+STARTUP: \\(.*\\)"))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 `(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
648 ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 'org-mode-restart))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650 ((or (eolp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 (and (looking-at "\\( \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\( \\|\t\\)+$")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 (looking-back " \\|\t")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 (org-mouse-popup-global-menu))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 ((get-context :checkbox)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 '(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 ["Toggle" org-toggle-checkbox t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 ["Remove" org-mouse-remove-match-and-spaces t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659 ""
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 ["All Clear" (org-mouse-for-each-item
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 (lambda ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 (when (save-excursion (org-at-item-checkbox-p))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663 (replace-match "[ ]"))))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 ["All Set" (org-mouse-for-each-item
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665 (lambda ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 (when (save-excursion (org-at-item-checkbox-p))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 (replace-match "[X]"))))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 ["All Toggle" (org-mouse-for-each-item 'org-toggle-checkbox) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669 ["All Remove" (org-mouse-for-each-item
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 (lambda ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 (when (save-excursion (org-at-item-checkbox-p))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 (org-mouse-remove-match-and-spaces))))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 )))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 ((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675 (member (match-string 0) (org-mouse-todo-keywords)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677 `(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678 ,@(org-mouse-keyword-replace-menu (org-mouse-todo-keywords))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680 ["Check TODOs" org-show-todo-tree t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
681 ["List all TODO keywords" org-todo-list t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 [,(format "List only %s" (match-string 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 (org-todo-list (match-string 0)) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684 )))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685 ((and (org-mouse-looking-at "\\b[A-Z]+:" "A-Z")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 (member (match-string 0) stamp-prefixes))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 `(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 ,@(org-mouse-keyword-replace-menu stamp-prefixes)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 ["Check Deadlines" org-check-deadlines t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 )))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 (popup-menu `(nil ,@(org-mouse-keyword-replace-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 (org-mouse-priority-list) 1 "Priority %s" t))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 ((get-context :link)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 '(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 ["Open" org-open-at-point t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 ["Open in Emacs" (org-open-at-point t) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 ["Copy link" (kill-new (match-string 0))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 ["Cut link"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 (progn
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 (kill-region (match-beginning 0) (match-end 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 (just-one-space))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 ["Grep for TODOs"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 (grep (format "grep -nH -i 'todo\\|fixme' %s*" (match-string 2)))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 ; ["Paste file link" ((insert "file:") (yank))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 )))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 ((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 `(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 [,(format "Display '%s'" (match-string 1))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 (org-tags-view nil ,(match-string 1))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 [,(format "Sparse Tree '%s'" (match-string 1))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 (org-tags-sparse-tree nil ,(match-string 1))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 ,@(org-mouse-tag-menu))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 ((org-at-timestamp-p)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 '(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 ["Show Day" org-open-at-point t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 ["Change Timestamp" org-time-stamp t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 ["Delete Timestamp" (org-mouse-delete-timestamp) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 ["Compute Time Range" org-evaluate-time-range (org-at-date-range-p)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 ["Set for Today" org-mouse-timestamp-today]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 ["Set for Tomorrow" (org-mouse-timestamp-today 1 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 ["Set in 1 Week" (org-mouse-timestamp-today 7 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 ["Set in 2 Weeks" (org-mouse-timestamp-today 14 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 ["Set in a Month" (org-mouse-timestamp-today 1 'month)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 ["+ 1 Day" (org-timestamp-change 1 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 ["+ 1 Week" (org-timestamp-change 7 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 ["+ 1 Month" (org-timestamp-change 1 'month)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 ["- 1 Day" (org-timestamp-change -1 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 ["- 1 Week" (org-timestamp-change -7 'day)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 ["- 1 Month" (org-timestamp-change -1 'month)])))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 ((get-context :table-special)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 (let ((mdata (match-data)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 (incf (car mdata) 2)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 (store-match-data mdata))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 (message "match: %S" (match-string 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747 (popup-menu `(nil ,@(org-mouse-keyword-replace-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 '(" " "!" "^" "_" "$" "#" "*" "'") 0
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 (lambda (mark)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 (case (string-to-char mark)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 (? "( ) Nothing Special")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 (?! "(!) Column Names")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 (?^ "(^) Field Names Above")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 (?_ "(^) Field Names Below")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 (?$ "($) Formula Parameters")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 (?# "(#) Recalculation: Auto")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 (?* "(*) Recalculation: Manual")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758 (?' "(') Recalculation: None"))) t))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 ((assq :table contextlist)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 '(nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762 ["Align Table" org-ctrl-c-ctrl-c]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 ["Blank Field" org-table-blank-field]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 ["Edit Field" org-table-edit-field]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 ("Column"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767 ["Move Column Left" org-metaleft]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 ["Move Column Right" org-metaright]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 ["Delete Column" org-shiftmetaleft]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 ["Insert Column" org-shiftmetaright]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 ["Enable Narrowing" (setq org-table-limit-column-width (not org-table-limit-column-width)) :selected org-table-limit-column-width :style toggle])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 ("Row"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 ["Move Row Up" org-metaup]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 ["Move Row Down" org-metadown]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 ["Delete Row" org-shiftmetaup]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 ["Insert Row" org-shiftmetadown]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778 ["Sort lines in region" org-table-sort-lines (org-at-table-p)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
780 ["Insert Hline" org-table-insert-hline])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781 ("Rectangle"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 ["Copy Rectangle" org-copy-special]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 ["Cut Rectangle" org-cut-special]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784 ["Paste Rectangle" org-paste-special]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 ["Fill Rectangle" org-table-wrap-region])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 ["Set Column Formula" org-table-eval-formula]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788 ["Set Field Formula" (org-table-eval-formula '(4))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 ["Edit Formulas" org-table-edit-formulas]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 ["Recalculate Line" org-table-recalculate]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 ["Recalculate All" (org-table-recalculate '(4))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 ["Iterate All" (org-table-recalculate '(16))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795 ["Toggle Recalculate Mark" org-table-rotate-recalc-marks]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 ["Sum Column/Rectangle" org-table-sum
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797 :active (or (org-at-table-p) (org-region-active-p))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 ["Field Info" org-table-field-info]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 ["Debug Formulas"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 (setq org-table-formula-debug (not org-table-formula-debug))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801 :style toggle :selected org-table-formula-debug]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 )))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 ((and (assq :headline contextlist) (not (eolp)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 (let ((priority (org-mouse-get-priority t)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806 `("Headline Menu"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 ("Tags and Priorities"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
808 ,@(org-mouse-keyword-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
809 (org-mouse-priority-list)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 '(lambda (keyword)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
811 (org-mouse-set-priority (string-to-char keyword)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812 priority "Priority %s")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 ,@(org-mouse-tag-menu))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 ("TODO Status"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 ,@(progn (org-mouse-match-todo-keyword)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817 (org-mouse-keyword-replace-menu (org-mouse-todo-keywords)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 1)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819 ["Show Tags"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
820 (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
821 :visible (not org-mouse-direct)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822 ["Show Priority"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 :visible (not org-mouse-direct)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 ,@(if org-mouse-direct '("--") nil)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826 ["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 ["Set Deadline"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 (progn (org-mouse-end-headline) (insert " ") (org-deadline))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 :active (not (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 (org-mouse-re-search-line org-deadline-regexp)))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 ["Schedule Task"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 (progn (org-mouse-end-headline) (insert " ") (org-schedule))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 :active (not (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 (org-mouse-re-search-line org-scheduled-regexp)))]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 ["Insert Timestamp"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 (progn (org-mouse-end-headline) (insert " ") (org-time-stamp nil)) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
837 ; ["Timestamp (inactive)" org-time-stamp-inactive t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 ["Archive Subtree" org-archive-subtree]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 ["Cut Subtree" org-cut-special]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841 ["Copy Subtree" org-copy-special]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
842 ["Paste Subtree" org-paste-special :visible org-mouse-direct]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 ("Sort Children"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844 ["Alphabetically" (org-sort-entries nil ?a)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845 ["Numerically" (org-sort-entries nil ?n)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846 ["By Time/Date" (org-sort-entries nil ?t)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 ["Reverse Alphabetically" (org-sort-entries nil ?A)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 ["Reverse Numerically" (org-sort-entries nil ?N)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850 ["Reverse By Time/Date" (org-sort-entries nil ?T)])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 ["Move Trees" org-mouse-move-tree :active nil]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 ))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854 (t
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855 (org-mouse-popup-global-menu))))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 ;; (defun org-mouse-at-regexp (regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
858 ;; (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859 ;; (let ((point (point))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860 ;; (bol (progn (beginning-of-line) (point)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 ;; (eol (progn (end-of-line) (point))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 ;; (goto-char point)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 ;; (re-search-backward regexp bol 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864 ;; (and (not (eolp))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 ;; (progn (forward-char)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 ;; (re-search-forward regexp eol t))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 ;; (<= (match-beginning 0) point)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 (defun org-mouse-mark-active ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870 (and mark-active transient-mark-mode))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 (defun org-mouse-in-region-p (pos)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873 (and (org-mouse-mark-active)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 (>= pos (region-beginning))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
875 (< pos (region-end))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
877 (defun org-mouse-down-mouse (event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
878 (interactive "e")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
879 (setq this-command last-command)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880 (unless (and (= 1 (event-click-count event))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 (org-mouse-in-region-p (posn-point (event-start event))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
882 (mouse-drag-region event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
883
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
884 (add-hook 'org-mode-hook
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
885 '(lambda ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
886 (setq org-mouse-context-menu-function 'org-mouse-context-menu)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
887
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
888 ; (define-key org-mouse-map [follow-link] 'mouse-face)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
889 (define-key org-mouse-map (if (featurep 'xemacs) [button3] [mouse-3]) nil)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 (define-key org-mode-map [mouse-3] 'org-mouse-show-context-menu)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 (define-key org-mode-map [down-mouse-1] 'org-mouse-down-mouse)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
892 (define-key org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
893 (define-key org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
894 (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895 (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
896 (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
897 (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 (font-lock-add-keywords nil
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
900 `((,outline-regexp
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 0 `(face org-link mouse-face highlight keymap ,org-mouse-map)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 'prepend)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904 (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) 'prepend))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905 ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 (2 `(face bold keymap ,org-mouse-map mouse-face highlight) t)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907 t)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909 (defadvice org-open-at-point (around org-mouse-open-at-point activate)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (let ((context (org-context)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911 (cond
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912 ((assq :headline-stars context) (org-cycle))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 ((assq :checkbox context) (org-toggle-checkbox))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 ((assq :item-bullet context)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 (let ((org-cycle-include-plain-lists t)) (org-cycle)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (t ad-do-it))))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 (defun org-mouse-move-tree-start (event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 (interactive "e")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 (message "Same line: promote/demote, (***):move before, (text): make a child"))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923 (defun org-mouse-make-marker (position)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924 (with-current-buffer (window-buffer (posn-window position))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 (copy-marker (posn-point position))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 (defun org-mouse-move-tree (event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
928 ;; todo: handle movements between different buffers
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 (interactive "e")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 (let* ((start (org-mouse-make-marker (event-start event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932 (end (org-mouse-make-marker (event-end event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 (sbuf (marker-buffer start))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (ebuf (marker-buffer end)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
936 (when (and sbuf ebuf)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
937 (set-buffer sbuf)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 (goto-char start)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
939 (org-back-to-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 (if (and (eq sbuf ebuf)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 (equal
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942 (point)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 (save-excursion (goto-char end) (org-back-to-heading) (point))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 ;; if the same line then promote/demote
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 (if (>= end start) (org-demote-subtree) (org-promote-subtree))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946 ;; if different lines then move
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 (org-cut-subtree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
948
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
949 (set-buffer ebuf)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
950 (goto-char end)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 (org-back-to-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 (when (and (eq sbuf ebuf)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953 (equal
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954 (point)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 (save-excursion (goto-char start)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956 (org-back-to-heading) (point))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 (outline-end-of-subtree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958 (end-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 (if (eobp) (newline) (forward-char)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
961 (when (looking-at outline-regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962 (let ((level (- (match-end 0) (match-beginning 0))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 (when (> end (match-end 0))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 (outline-end-of-subtree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
965 (end-of-line)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 (if (eobp) (newline) (forward-char))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 (setq level (1+ level)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968 (org-paste-subtree level)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (outline-end-of-subtree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971 (when (bolp) (delete-char -1))))))))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 (defun org-mouse-transform-to-outline ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 (interactive)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976 (org-back-to-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 (let ((minlevel 1000)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
978 (replace-text (concat (match-string 0) "* ")))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
979 (beginning-of-line 2)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 (while (not (or (eobp) (looking-at outline-regexp)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 (when (looking-at org-mouse-plain-list-regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 (setq minlevel (min minlevel (- (match-end 1) (match-beginning 1)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 (forward-line)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 (while (not (or (eobp) (looking-at outline-regexp)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 (when (and (looking-at org-mouse-plain-list-regexp)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 (eq minlevel (- (match-end 1) (match-beginning 1))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 (replace-match replace-text))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 (forward-line))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 (defvar _cmd) ;dynamically scoped from `org-with-remote-undo'.
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 (defun org-mouse-do-remotely (command)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 ; (org-agenda-check-no-diary)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
995 (when (get-text-property (point) 'org-marker)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996 (let* ((anticol (- (point-at-eol) (point)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 (marker (get-text-property (point) 'org-marker))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 (buffer (marker-buffer marker))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999 (pos (marker-position marker))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 (hdmarker (get-text-property (point) 'org-hd-marker))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 (buffer-read-only nil)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 (newhead "--- removed ---")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 (org-mouse-direct nil)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 (org-mouse-main-buffer (current-buffer)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 (when (eq (with-current-buffer buffer major-mode) 'org-mode)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 (let ((endmarker (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 (set-buffer buffer)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 (outline-end-of-subtree)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 (forward-char 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 (copy-marker (point)))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 (org-with-remote-undo buffer
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 (with-current-buffer buffer
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013 (widen)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (goto-char pos)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 (org-show-hidden-entry)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1016 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 (and (outline-next-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 (org-flag-heading nil))) ; show the next heading
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 (org-back-to-heading)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020 (setq marker (copy-marker (point)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 (goto-char (max (point-at-bol) (- (point-at-eol) anticol)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 (funcall command)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 (message "_cmd: %S" _cmd)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 (message "this-command: %S" this-command)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025 (unless (eq (marker-position marker) (marker-position endmarker))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 (setq newhead (org-get-heading))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 (beginning-of-line 1)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 (save-excursion
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030 (org-agenda-change-all-lines newhead hdmarker 'fixface))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 t))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1033 (defun org-mouse-agenda-context-menu (&optional event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 (or (org-mouse-do-remotely 'org-mouse-context-menu)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1035 (popup-menu
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1036 '("Agenda"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1037 ("Agenda Files")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 ["Undo" (progn (message "last command: %S" last-command) (setq this-command 'org-agenda-undo) (org-agenda-undo))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1040 :visible (if (eq last-command 'org-agenda-undo)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041 org-agenda-pending-undo-list
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 org-agenda-undo-list)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 ["Rebuild Buffer" org-agenda-redo t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1044 ["New Diary Entry"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1045 org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1046 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1047 ["Goto Today" org-agenda-goto-today
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048 (org-agenda-check-type nil 'agenda 'timeline) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049 ["Display Calendar" org-agenda-goto-calendar
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050 (org-agenda-check-type nil 'agenda 'timeline) t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 ("Calendar Commands"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 ["Phases of the Moon" org-agenda-phases-of-moon
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 (org-agenda-check-type nil 'agenda 'timeline)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054 ["Sunrise/Sunset" org-agenda-sunrise-sunset
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (org-agenda-check-type nil 'agenda 'timeline)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1056 ["Holidays" org-agenda-holidays
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1057 (org-agenda-check-type nil 'agenda 'timeline)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1058 ["Convert" org-agenda-convert-date
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1059 (org-agenda-check-type nil 'agenda 'timeline)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 ["Create iCalendar file" org-export-icalendar-combine-agenda-files t])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063 ["Day View" org-agenda-day-view
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 :active (org-agenda-check-type nil 'agenda)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 :style radio :selected (equal org-agenda-ndays 1)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 ["Week View" org-agenda-week-view
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067 :active (org-agenda-check-type nil 'agenda)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 :style radio :selected (equal org-agenda-ndays 7)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1070 ["Show Logbook entries" org-agenda-log-mode
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071 :style toggle :selected org-agenda-show-log
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072 :active (org-agenda-check-type nil 'agenda 'timeline)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073 ["Include Diary" org-agenda-toggle-diary
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 :style toggle :selected org-agenda-include-diary
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 :active (org-agenda-check-type nil 'agenda)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076 ["Use Time Grid" org-agenda-toggle-time-grid
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 :style toggle :selected org-agenda-use-time-grid
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1078 :active (org-agenda-check-type nil 'agenda)]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079 ["Follow Mode" org-agenda-follow-mode
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 :style toggle :selected org-agenda-follow-mode]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 "--"
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1082 ["Quit" org-agenda-quit t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1083 ["Exit and Release Buffers" org-agenda-exit t]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1084 ))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1086 (defun org-mouse-get-gesture (event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1087 (let ((startxy (posn-x-y (event-start event)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088 (endxy (posn-x-y (event-end event))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 (if (< (car startxy) (car endxy)) :right :left)))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 ; (setq org-agenda-mode-hook nil)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 (add-hook 'org-agenda-mode-hook
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 '(lambda ()
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 (define-key org-agenda-keymap
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097 (if (featurep 'xemacs) [button3] [mouse-3])
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 'org-mouse-show-context-menu)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 (define-key org-agenda-keymap [down-mouse-3] 'org-mouse-move-tree-start)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 (define-key org-agenda-keymap [C-mouse-4] 'org-agenda-earlier)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101 (define-key org-agenda-keymap [C-mouse-5] 'org-agenda-later)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 (define-key org-agenda-keymap [drag-mouse-3]
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 '(lambda (event) (interactive "e")
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 (case (org-mouse-get-gesture event)
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 (:left (org-agenda-earlier 1))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106 (:right (org-agenda-later 1)))))))
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107
24a61b9ca04c New file
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 (provide 'org-mouse)
87846
50aec4a9ce08 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87841
diff changeset
1109
50aec4a9ce08 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87841
diff changeset
1110 ;; arch-tag: ff1ae557-3529-41a3-95c6-baaebdcc280f