comparison lisp/org/org-mouse.el @ 94414:d86cb59eea9f

2008-04-27 Carsten Dominik <dominik@science.uva.nl> * org/org.el (org-html-level-start): Always have id's in HTML (org-export-as-html): Use `org-link-protocols' to retrieve the export form of the link. (org-add-link-type): Final parameter renamed from PUBLISH. Better documentation of how it is to be used. Avoid double entries for the same link type. (org-add-link-props): New function. (org-modules-loaded): New variable. (org-load-modules-maybe, org-set-modules): New function. (org-modules): New option. (org-mode, org-cycle, orgstruct-mode, org-run-like-in-org-mode) (orgtbl-mode, org-store-link, org-insert-link-global) (org-open-at-point): Call `org-load-modules-maybe'. (org-search-view): Add more text properties. (org-agenda-schedule, org-agenda-deadline): Allow also in search-type agendas. (org-search-view): Order of arguments has been changed. Interpret prefix-arg as TODO-ONLY. (org-agenda, org-run-agenda-series, org-agenda-manipulate-query): Take new argument order of `org-search-view' into account. (org-todo-only): New variable. (org-search-syntax-table): New variable and function. (org-search-view): Do the search with the special syntax table. (define-obsolete-function-alias): Make work with XEmacs. (org-add-planning-info): Use old date as default when modifying an existing deadline or scheduled item. (org-agenda-compute-time-span): Make argument N optional. (org-agenda-format-date-aligned): Require `cal-iso'. (org-agenda-list): Include week into into agenda heading, don't list it at each date (only on Mondays). (org-read-date-analyze): Define local variable `iso-date'. (org-agenda-format-date-aligned): Remove dependency on `calendar-time-from-absolute'. (org-remember-apply-template, org-go-to-remember-target): Interpret filenames relative to `org-directory'. (org-complete): Silently fail when trying to complete keywords that don't have a default value. (org-get-current-options): Added a #+DATE: option. (org-additional-option-like-keywords): Removed "DATE:" from the list of additional keywords. (org-export-as-html): Removed (current-time) as unnecessary second argument of `format-time-string'. (org-clock-find-position): Handle special case at end of buffer. (org-agenda-day-view): New argument DAY-OF-YEAR, pass it on to `org-agenda-change-time-span'. (org-agenda-week-view): New argument ISO-WEEK, pass it on to `org-agenda-change-time-span'. (org-agenda-month-view): New argument MONTH, pass it on to `org-agenda-change-time-span'. (org-agenda-year-view): New argument YEAR, pass it on to `org-agenda-change-time-span'. (org-agenda-change-time-span): New optional argument N, pass it on to `org-agenda-compute-time-span'. (org-agenda-compute-time-span): New argument N, interpret it by changing the starting day. (org-small-year-to-year): New function. (org-scheduled-past-days): Respect `org-scheduled-past-days'. (org-auto-repeat-maybe): Make sure that repeating dates are pushed into the future, and that the shift is at least one interval, never 0. (org-update-checkbox-count): Fix bug with checkbox counting. (org-add-note): New command. (org-add-log-setup): Renamed from `org-add-log-maybe'. (org-log-note-headings): New entry for plain notes (i.e. notes not related to state changes or clocking). (org-get-org-file): Check for availability of `remember-data-file'. (org-cached-entry-get): Allow a regexp value for `org-use-property-inheritance'. (org-use-property-inheritance): Allow regexp value. Fix bug in customization type. (org-use-tag-inheritance): Allow a list and a regexp value for this variable. (org-scan-tags, org-get-tags-at): Implement selective tag inheritance. (org-entry-get): Respect value `selective' for the INHERIT argument. (org-tag-inherit-p, org-property-inherit-p): New functions. (org-agenda-format-date-aligned): Allow 10 characters for weekday, to acomodate German locale. (org-add-archive-files): New function. (org-agenda-files): New argument `ext', to get archive files as well. (org-tbl-menu): Protect the use of variables that are only available when org-table.el gets loaded. (org-read-agenda-file-list): Error if `org-agenda-files' is a single directory. (org-open-file): Allow a batch process to trigger waiting after executing a system command. (org-store-link): Link to headline when there is not target and no region in an org-mode buffer when creating a link. (org-link-types-re): New variable. (org-make-link-regexps): Compute `org-link-types-re'. (org-make-link-description-function): New option. (org-agenda-date, org-agenda-date-weekend): New faces. (org-archive-sibling-heading): New option. (org-archive-to-archive-sibling): New function. (org-iswitchb): New command. (org-buffer-list): New function. (org-agenda-columns): Also try the #+COLUMNS line in the buffer associated with the entry at point (or with the first entry in the agenda view). (org-modules): Add entry for org-bibtex.el. (org-completion-fallback-command): Moved into `org-completion' group. (org-clock-heading-function): Moved to `org-progress' group. (org-auto-repeat-maybe): Make sure that a note can be enforces if `org-log-repeat' is `note'. (org-modules): Allow additional symbols for external packages. (org-ctrl-c-ctrl-c): Allow for `org-clock-overlays' to be undefined. (org-clock-goto): Hide drawers after showing an entry with `org-clock-goto.' (org-shiftup, org-shiftdown, org-shiftright, org-shiftleft): Try also a clocktable block shift. (org-clocktable-try-shift): New function. (org-columns-hscoll-title): New function. (org-columns-previous-hscroll): New variable. (org-columns-full-header-line-format): New variable. (org-columns-display-here-title, org-columns-remove-overlays): Install `org-columns-hscoll-title' in post-command-hook. * org/org.el: Split into many small files. * org/org-agenda.el: New file, split off from org.el. * org/org-archive.el: New file, split off from org.el. * org/org-bbdb.el: New file. * org/org-bibtex.el: New file, split off from org.el. * org/org-clock.el: New file, split off from org.el. * org/org-colview.el: New file, split off from org.el. * org/org-compat.el: New file, split off from org.el. * org/org-exp.el: New file, split off from org.el. * org/org-faces.el: New file, split off from org.el. * org/org-gnus.el: New file, split off from org.el. * org/org-info.el: New file, split off from org.el. * org/org-infojs.el: New file. * org/org-irc.el: New file. * org/org-macs.el: New file, split off from org.el. * org/org-mew.el: New file. * org/org-mhe.el: New file, split off from org.el. * org/org-publish.el: New file, split off from org.el. * org/org-remember.el: New file, split off from org.el. * org/org-rmail.el: New file, split off from org.el. * org/org-table.el: New file, split off from org.el. * org/org-vm.el: New file, split off from org.el. * org/org-wl.el: New file, split off from org.el. 2008-04-27 Jason Riedy <jason@acm.org> * lisp/org-table.el (orgtbl-to-generic): Add a :remove-nil-lines parameter that supresses lines that evaluate to NIL. (orgtbl-get-fmt): New inline function for picking apart formats that may be lists. (orgtbl-apply-fmt): New inline function for applying formats that may be functions. (orgtbl-eval-str): New inline function for strings that may be functions. (orgtbl-format-line, orgtbl-to-generic): Use and document. (orgtbl-to-latex, orgtbl-to-texinfo): Document. (*orgtbl-llfmt*, *orgtbl-llstart*) (*orgtbl-llend*): Dynamic variables for last-line formatting. (orgtbl-format-section): Shift formatting to support detecting the last line and formatting it specially. (orgtbl-to-generic): Document :ll* formats. Set to the non-ll formats unless overridden. (orgtbl-to-latex): Suggest using :llend to suppress the final \\. (*orgtbl-table*, *orgtbl-rtn*): Dynamically bound variables to hold the input collection of lines and output formatted text. (*orgtbl-hline*, *orgtbl-sep*, *orgtbl-fmt*, *orgtbl-efmt*, (*orgtbl-lfmt*, *orgtbl-lstart*, *orgtbl-lend*): Dynamically bound format parameters. (orgtbl-format-line): New function encapsulating formatting for a single line. (orgtbl-format-section): Similar for each section. Rebinding the dynamic vars customizes the formatting for each section. (orgtbl-to-generic): Use orgtbl-format-line and orgtbl-format-section. (org-get-param): Now unused, so delete. (orgtbl-gather-send-defs): New function to gather all the SEND definitions before a table. (orgtbl-send-replace-tbl): New function to find the RECEIVE corresponding to the current name. (orgtbl-send-table): Use the previous two functions and implement multiple destinations for each table. * doc/org.texi (A LaTeX example): Note that fmt may be a one-argument function, and efmt may be a two-argument function. (Radio tables): Document multiple destinations. 2008-04-27 Carsten Dominik <dominik@science.uva.nl> * org/org-agenda.el (org-add-to-diary-list): New function. (org-prefix-has-effort): New variable. (org-sort-agenda-noeffort-is-high): New option. (org-agenda-columns-show-summaries) (org-agenda-columns-compute-summary-properties): New options. (org-format-agenda-item): Compute the duration of the item. (org-agenda-weekend-days): New variable. (org-agenda-list, org-timeline): Use the proper faces for dates in the agenda and timeline buffers. (org-agenda-archive-to-archive-sibling): New command. (org-agenda-start-with-clockreport-mode): New option. (org-agenda-clockreport-parameter-plist): New option. (org-agenda-clocktable-mode): New variable. (org-agenda-deadline-leaders): Allow a function value for the deadline leader. (org-agenda-get-deadlines): Deal with new function value. * lisp/org-clock.el (org-clock): New customization group. (org-clock-into-drawer, org-clock-out-when-done) (org-clock-in-switch-to-state, org-clock-heading-function): Moved into the new group. (org-clock-out-remove-zero-time-clocks): New option. (org-clock-out): Use `org-clock-out-remove-zero-time-clocks'. (org-dblock-write:clocktable): Allow a Lisp form for the scope parameter. (org-dblock-write:clocktable): Fixed bug with total time calculation. (org-dblock-write:clocktable): Request the unrestricted list of files. (org-get-clocktable): New function. (org-dblock-write:clocktable): Make sure :tstart and :tend can not only be strings but also integers (an absolute day number) and lists (m d y). * org/org-colview.el (org-columns-next-allowed-value) (org-columns-edit-value): Limit the effort for updatig in the agenda to recomputing a single file. (org-columns-compute): Only write property value if it has changed. This avoids raising the buffer-change-flag unnecessarily. (org-agenda-colview-summarize) (org-agenda-colview-compute): New functions. (org-agenda-columns): Call `org-agenda-colview-summarize'. * org/org-exp.el (org-export-run-in-background): New option. (org-export-icalendar): Allow a batch process to trigger waiting after executing a system command. (org-export-preprocess-string): Renamed-from `org-cleaned-string-for-export'. (org-export-html-style): Made target class look like normal text. (org-export-as-html): Make use of the better proprocessing in `org-cleaned-string-for-export'. (org-cleaned-string-for-export): Better treatment of heuristic targets, many more internal links will now work in HTML export. (org-get-current-options): Incorporate LINK_UP, LINK_HOME, and INFOJS. (org-export-inbuffer-options-extra): New variable. (org-export-options-filters): New hook. (org-infile-export-plist): Find also the settings keywords in `org-export-inbuffer-options-extra'. (org-infile-export-plist): Allow multiple #+OPTIONS lines and multiple #+INFOJS_OPT lines. (org-export-html-handle-js-options): New function. (org-export-html-infojs-setup): New option. (org-export-as-html): Call `org-export-html-handle-js-options'. Add autoload to all entry points. (org-skip-comments): Function removed. * org/org-table.el (org-table-make-reference): Extra parenthesis around single fields, to make sure that algebraic formulas get correctly interpreted by calc. (org-table-current-column): No longer interactive. * org/org-export-latex.el (org-export-latex-preprocess): Renamed from `org-export-latex-cleaned-string'. 2008-04-27 Bastien Guerry <bzg@altern.org> * org/org-publish.el (org-publish-get-base-files-1): New function. (org-publish-get-base-files): Use it. (org-publish-temp-files): New variable. Don't require 'dired-aux anymore. (org-publish-initial-buffer): New variable. (org-publish-org-to, org-publish): Use it. (org-publish-get-base-files-1): Bug fix: get the proper list of files when recursing thru a directory. (org-publish-get-base-files): Use the :exclude property to skip both files and directories.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 27 Apr 2008 18:33:39 +0000
parents dda2c82177dc
children ba3167bc4143
comparison
equal deleted inserted replaced
94413:90289baecd6a 94414:d86cb59eea9f
2 2
3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation 3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation
4 ;; 4 ;;
5 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com> 5 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
6 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org> 6 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
7 ;; Version: 5.23 7 ;; Version: 6.02b
8 ;; 8 ;;
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
10 ;; 10 ;;
11 ;; GNU Emacs is free software; you can redistribute it and/or modify 11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by 12 ;; it under the terms of the GNU General Public License as published by
40 ;; + priorities 40 ;; + priorities
41 ;; + links 41 ;; + links
42 ;; + tags 42 ;; + tags
43 ;; * promoting/demoting/moving subtrees with mouse-3 43 ;; * promoting/demoting/moving subtrees with mouse-3
44 ;; + if the drag starts and ends in the same line then promote/demote 44 ;; + if the drag starts and ends in the same line then promote/demote
45 ;; + otherwise move the subtree 45 ;; + otherwise move the subtree
46 ;; 46 ;;
47 ;; Use 47 ;; Use
48 ;; --- 48 ;; ---
49 ;; 49 ;;
50 ;; To use this package, put the following line in your .emacs: 50 ;; To use this package, put the following line in your .emacs:
91 ;; Version 0.21 91 ;; Version 0.21
92 ;; + selected text activates its context menu 92 ;; + selected text activates its context menu
93 ;; + shift-middleclick or right-drag inserts the text from the clipboard in the form of a link 93 ;; + shift-middleclick or right-drag inserts the text from the clipboard in the form of a link
94 ;; 94 ;;
95 ;; Version 0.20 95 ;; Version 0.20
96 ;; + the new "TODO Status" submenu replaces the "Cycle TODO" menu item 96 ;; + the new "TODO Status" submenu replaces the "Cycle TODO" menu item
97 ;; + the TODO menu can now list occurrences of a specific TODO keyword 97 ;; + the TODO menu can now list occurrences of a specific TODO keyword
98 ;; + #+STARTUP line is now recognized 98 ;; + #+STARTUP line is now recognized
99 ;; 99 ;;
100 ;; Version 0.19 100 ;; Version 0.19
101 ;; + added support for dragging URLs to the org-buffer 101 ;; + added support for dragging URLs to the org-buffer
113 ;; + org-mode now works with the Agenda buffer as well 113 ;; + org-mode now works with the Agenda buffer as well
114 ;; 114 ;;
115 ;; Version 0.14 115 ;; Version 0.14
116 ;; + added a menu option that converts plain list items to outline items 116 ;; + added a menu option that converts plain list items to outline items
117 ;; 117 ;;
118 ;; Version 0.13 118 ;; Version 0.13
119 ;; + "Insert Heading" now inserts a sibling heading if the point is 119 ;; + "Insert Heading" now inserts a sibling heading if the point is
120 ;; on "***" and a child heading otherwise 120 ;; on "***" and a child heading otherwise
121 ;; 121 ;;
122 ;; Version 0.12 122 ;; Version 0.12
123 ;; + compatible with Emacs 21 123 ;; + compatible with Emacs 21
124 ;; + custom agenda commands added to the main menu 124 ;; + custom agenda commands added to the main menu
125 ;; + moving trees should now work between windows in the same frame 125 ;; + moving trees should now work between windows in the same frame
126 ;; 126 ;;
130 ;; 130 ;;
131 ;; Version 0.10 131 ;; Version 0.10
132 ;; + added a menu option to remove highlights 132 ;; + added a menu option to remove highlights
133 ;; + compatible with org-mode 4.21 now 133 ;; + compatible with org-mode 4.21 now
134 ;; 134 ;;
135 ;; Version 0.08: 135 ;; Version 0.08:
136 ;; + trees can be moved/promoted/demoted by dragging with the right 136 ;; + trees can be moved/promoted/demoted by dragging with the right
137 ;; mouse button (mouse-3) 137 ;; mouse button (mouse-3)
138 ;; + small changes in the above function 138 ;; + small changes in the above function
139 ;; 139 ;;
140 ;; Versions 0.01 -- 0.07: (I don't remember) 140 ;; Versions 0.01 -- 0.07: (I don't remember)
141 141
142 (eval-when-compile (require 'cl)) 142 (eval-when-compile (require 'cl))
143 (require 'org) 143 (require 'org)
144
145 (defvar org-agenda-allow-remote-undo)
146 (defvar org-agenda-undo-list)
147 (defvar org-agenda-custom-commands)
148 (declare-function org-agenda-change-all-lines "org-agenda"
149 (newhead hdmarker &optional fixface))
150 (declare-function org-verify-change-for-undo "org-agenda" (l1 l2))
144 151
145 (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " 152 (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
146 "Regular expression that matches a plain list.") 153 "Regular expression that matches a plain list.")
147 (defvar org-mouse-direct t 154 (defvar org-mouse-direct t
148 "Internal variable indicating whether the current action is direct. 155 "Internal variable indicating whether the current action is direct.
184 191
185 (defun org-mouse-show-context-menu (event prefix) 192 (defun org-mouse-show-context-menu (event prefix)
186 "Invoke the context menu. 193 "Invoke the context menu.
187 194
188 If the value of `org-mouse-context-menu-function' is a function, then 195 If the value of `org-mouse-context-menu-function' is a function, then
189 this function is called. Otherwise, the current major mode menu is used." 196 this function is called. Otherwise, the current major mode menu is used."
190 (interactive "@e \nP") 197 (interactive "@e \nP")
191 (if (and (= (event-click-count event) 1) 198 (if (and (= (event-click-count event) 1)
192 (or (not mark-active) 199 (or (not mark-active)
193 (sit-for (/ double-click-time 1000.0)))) 200 (sit-for (/ double-click-time 1000.0))))
194 (progn 201 (progn
195 (select-window (posn-window (event-start event))) 202 (select-window (posn-window (event-start event)))
196 (when (not (org-mouse-mark-active)) 203 (when (not (org-mouse-mark-active))
197 (goto-char (posn-point (event-start event))) 204 (goto-char (posn-point (event-start event)))
241 (:beginning (beginning-of-line) 248 (:beginning (beginning-of-line)
242 (org-insert-heading)) 249 (org-insert-heading))
243 (t (org-mouse-next-heading) 250 (t (org-mouse-next-heading)
244 (org-insert-heading)))) 251 (org-insert-heading))))
245 252
246 (defun org-mouse-timestamp-today (&optional shift units) 253 (defun org-mouse-timestamp-today (&optional shift units)
247 "Change the timestamp into SHIFT UNITS in the future. 254 "Change the timestamp into SHIFT UNITS in the future.
248 255
249 For the acceptable UNITS, see `org-timestamp-change'." 256 For the acceptable UNITS, see `org-timestamp-change'."
250 (interactive) 257 (interactive)
251 (flet ((org-read-date (&rest rest) (current-time))) 258 (flet ((org-read-date (&rest rest) (current-time)))
252 (org-time-stamp nil)) 259 (org-time-stamp nil))
263 If SELECTED is nil, then all items are normal menu items. If 270 If SELECTED is nil, then all items are normal menu items. If
264 SELECTED is a function, then each item is a checkbox, which is 271 SELECTED is a function, then each item is a checkbox, which is
265 enabled for a given keyword iff (funcall SELECTED keyword) return 272 enabled for a given keyword iff (funcall SELECTED keyword) return
266 non-nil. If SELECTED is neither nil nor a function, then the 273 non-nil. If SELECTED is neither nil nor a function, then the
267 items are radio buttons. A radio button is enabled for the 274 items are radio buttons. A radio button is enabled for the
268 keyword `equal' to SELECTED. 275 keyword `equal' to SELECTED.
269 276
270 ITEMFORMAT governs formatting of the elements of KEYWORDS. If it 277 ITEMFORMAT governs formatting of the elements of KEYWORDS. If it
271 is a function, it is invoked with the keyword as the only 278 is a function, it is invoked with the keyword as the only
272 argument. If it is a string, it is interpreted as the format 279 argument. If it is a string, it is interpreted as the format
273 string to (format ITEMFORMAT keyword). If it is neither a string 280 string to (format ITEMFORMAT keyword). If it is neither a string
274 nor a function, elements of KEYWORDS are used directly. " 281 nor a function, elements of KEYWORDS are used directly. "
275 (mapcar 282 (mapcar
276 `(lambda (keyword) 283 `(lambda (keyword)
277 (vector (cond 284 (vector (cond
278 ((functionp ,itemformat) (funcall ,itemformat keyword)) 285 ((functionp ,itemformat) (funcall ,itemformat keyword))
279 ((stringp ,itemformat) (format ,itemformat keyword)) 286 ((stringp ,itemformat) (format ,itemformat keyword))
280 (t keyword)) 287 (t keyword))
281 (list 'funcall ,function keyword) 288 (list 'funcall ,function keyword)
282 :style (cond 289 :style (cond
283 ((null ,selected) t) 290 ((null ,selected) t)
284 ((functionp ,selected) 'toggle) 291 ((functionp ,selected) 'toggle)
285 (t 'radio)) 292 (t 'radio))
286 :selected (if (functionp ,selected) 293 :selected (if (functionp ,selected)
287 (and (funcall ,selected keyword) t) 294 (and (funcall ,selected keyword) t)
288 (equal ,selected keyword)))) 295 (equal ,selected keyword))))
289 keywords)) 296 keywords))
290 297
291 (defun org-mouse-remove-match-and-spaces () 298 (defun org-mouse-remove-match-and-spaces ()
292 "Remove the match, make just one space around the point." 299 "Remove the match, make just one space around the point."
293 (interactive) 300 (interactive)
294 (replace-match "") 301 (replace-match "")
295 (just-one-space)) 302 (just-one-space))
296 303
297 (defvar rest) 304 (defvar rest)
298 (defun org-mouse-replace-match-and-surround (newtext &optional fixedcase 305 (defun org-mouse-replace-match-and-surround (newtext &optional fixedcase
299 literal string subexp) 306 literal string subexp)
300 "The same as `replace-match', but surrounds the replacement with spaces." 307 "The same as `replace-match', but surrounds the replacement with spaces."
301 (apply 'replace-match rest) 308 (apply 'replace-match rest)
302 (save-excursion 309 (save-excursion
303 (goto-char (match-beginning (or subexp 0))) 310 (goto-char (match-beginning (or subexp 0)))
304 (just-one-space) 311 (just-one-space)
305 (goto-char (match-end (or subexp 0))) 312 (goto-char (match-end (or subexp 0)))
306 (just-one-space))) 313 (just-one-space)))
307 314
308 315
309 (defun org-mouse-keyword-replace-menu (keywords &optional group itemformat 316 (defun org-mouse-keyword-replace-menu (keywords &optional group itemformat
310 nosurround) 317 nosurround)
311 "A helper function. 318 "A helper function.
312 319
321 328
322 ITEMFORMAT governs formatting of the elements of KEYWORDS. If it 329 ITEMFORMAT governs formatting of the elements of KEYWORDS. If it
323 is a function, it is invoked with the keyword as the only 330 is a function, it is invoked with the keyword as the only
324 argument. If it is a string, it is interpreted as the format 331 argument. If it is a string, it is interpreted as the format
325 string to (format ITEMFORMAT keyword). If it is neither a string 332 string to (format ITEMFORMAT keyword). If it is neither a string
326 nor a function, elements of KEYWORDS are used directly. 333 nor a function, elements of KEYWORDS are used directly.
327 " 334 "
328 (setq group (or group 0)) 335 (setq group (or group 0))
329 (let ((replace (org-mouse-match-closure 336 (let ((replace (org-mouse-match-closure
330 (if nosurround 'replace-match 337 (if nosurround 'replace-match
331 'org-mouse-replace-match-and-surround)))) 338 'org-mouse-replace-match-and-surround))))
332 (append 339 (append
333 (org-mouse-keyword-menu 340 (org-mouse-keyword-menu
334 keywords 341 keywords
335 `(lambda (keyword) (funcall ,replace keyword t t nil ,group)) 342 `(lambda (keyword) (funcall ,replace keyword t t nil ,group))
336 (match-string group) 343 (match-string group)
337 itemformat) 344 itemformat)
338 `(["None" org-mouse-remove-match-and-spaces 345 `(["None" org-mouse-remove-match-and-spaces
339 :style radio 346 :style radio
340 :selected ,(not (member (match-string group) keywords))])))) 347 :selected ,(not (member (match-string group) keywords))]))))
341 348
342 (defun org-mouse-show-headlines () 349 (defun org-mouse-show-headlines ()
343 "Change the visibility of the current org buffer to only show headlines." 350 "Change the visibility of the current org buffer to only show headlines."
344 (interactive) 351 (interactive)
345 (let ((this-command 'org-cycle) 352 (let ((this-command 'org-cycle)
346 (last-command 'org-cycle) 353 (last-command 'org-cycle)
347 (org-cycle-global-status nil)) 354 (org-cycle-global-status nil))
348 (org-cycle '(4)) 355 (org-cycle '(4))
349 (org-cycle '(4)))) 356 (org-cycle '(4))))
350 357
351 (defun org-mouse-show-overview () 358 (defun org-mouse-show-overview ()
352 "Change visibility of current org buffer to first-level headlines only." 359 "Change visibility of current org buffer to first-level headlines only."
353 (interactive) 360 (interactive)
354 (let ((org-cycle-global-status nil)) 361 (let ((org-cycle-global-status nil))
355 (org-cycle '(4)))) 362 (org-cycle '(4))))
356 363
357 (defun org-mouse-set-priority (priority) 364 (defun org-mouse-set-priority (priority)
358 "Set the priority of the current headline to PRIORITY." 365 "Set the priority of the current headline to PRIORITY."
365 leading '.*?'.") 372 leading '.*?'.")
366 373
367 (defun org-mouse-get-priority (&optional default) 374 (defun org-mouse-get-priority (&optional default)
368 "Return the priority of the current headline. 375 "Return the priority of the current headline.
369 DEFAULT is returned if no priority is given in the headline." 376 DEFAULT is returned if no priority is given in the headline."
370 (save-excursion 377 (save-excursion
371 (if (org-mouse-re-search-line org-mouse-priority-regexp) 378 (if (org-mouse-re-search-line org-mouse-priority-regexp)
372 (match-string 1) 379 (match-string 1)
373 (when default (char-to-string org-default-priority))))) 380 (when default (char-to-string org-default-priority)))))
374 381
375 ;; (defun org-mouse-at-link () 382 ;; (defun org-mouse-at-link ()
388 (replace-match "") ; delete the timestamp 395 (replace-match "") ; delete the timestamp
389 (skip-chars-backward " :A-Z") 396 (skip-chars-backward " :A-Z")
390 (when (looking-at " *[A-Z][A-Z]+:") 397 (when (looking-at " *[A-Z][A-Z]+:")
391 (replace-match "")))) 398 (replace-match ""))))
392 399
393 (defun org-mouse-looking-at (regexp skipchars &optional movechars) 400 (defun org-mouse-looking-at (regexp skipchars &optional movechars)
394 (save-excursion 401 (save-excursion
395 (let ((point (point))) 402 (let ((point (point)))
396 (if (looking-at regexp) t 403 (if (looking-at regexp) t
397 (skip-chars-backward skipchars) 404 (skip-chars-backward skipchars)
398 (forward-char (or movechars 0)) 405 (forward-char (or movechars 0))
399 (when (looking-at regexp) 406 (when (looking-at regexp)
400 (> (match-end 0) point)))))) 407 (> (match-end 0) point))))))
401 408
402 (defun org-mouse-priority-list () 409 (defun org-mouse-priority-list ()
403 (loop for priority from ?A to org-lowest-priority 410 (loop for priority from ?A to org-lowest-priority
404 collect (char-to-string priority))) 411 collect (char-to-string priority)))
405 412
406 (defun org-mouse-tag-menu () ;todo 413 (defun org-mouse-tag-menu () ;todo
407 (append 414 (append
408 (let ((tags (org-split-string (org-get-tags) ":"))) 415 (let ((tags (org-split-string (org-get-tags) ":")))
409 (org-mouse-keyword-menu 416 (org-mouse-keyword-menu
410 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp) 417 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
411 `(lambda (tag) 418 `(lambda (tag)
412 (org-mouse-set-tags 419 (org-mouse-set-tags
413 (sort (if (member tag (quote ,tags)) 420 (sort (if (member tag (quote ,tags))
414 (delete tag (quote ,tags)) 421 (delete tag (quote ,tags))
415 (cons tag (quote ,tags))) 422 (cons tag (quote ,tags)))
416 'string-lessp))) 423 'string-lessp)))
417 `(lambda (tag) (member tag (quote ,tags))) 424 `(lambda (tag) (member tag (quote ,tags)))
418 )) 425 ))
419 '("--" 426 '("--"
420 ["Align Tags Here" (org-set-tags nil t) t] 427 ["Align Tags Here" (org-set-tags nil t) t]
421 ["Align Tags in Buffer" (org-set-tags t t) t] 428 ["Align Tags in Buffer" (org-set-tags t t) t]
422 ["Set Tags ..." (org-set-tags) t]))) 429 ["Set Tags ..." (org-set-tags) t])))
423 430
424 431
425 432
426 (defun org-mouse-set-tags (tags) 433 (defun org-mouse-set-tags (tags)
427 (save-excursion 434 (save-excursion
428 ;; remove existing tags first 435 ;; remove existing tags first
433 ;; set new tags if any 440 ;; set new tags if any
434 (when tags 441 (when tags
435 (end-of-line) 442 (end-of-line)
436 (insert " :" (mapconcat 'identity tags ":") ":") 443 (insert " :" (mapconcat 'identity tags ":") ":")
437 (org-set-tags nil t)))) 444 (org-set-tags nil t))))
438 445
439 (defun org-mouse-insert-checkbox () 446 (defun org-mouse-insert-checkbox ()
440 (interactive) 447 (interactive)
441 (and (org-at-item-p) 448 (and (org-at-item-p)
442 (goto-char (match-end 0)) 449 (goto-char (match-end 0))
443 (unless (org-at-item-checkbox-p) 450 (unless (org-at-item-checkbox-p)
453 ('occur-tree "Occur tree: ") 460 ('occur-tree "Occur tree: ")
454 (t "Agenda command ???"))) 461 (t "Agenda command ???")))
455 462
456 463
457 (defun org-mouse-list-options-menu (alloptions &optional function) 464 (defun org-mouse-list-options-menu (alloptions &optional function)
458 (let ((options (save-match-data 465 (let ((options (save-match-data
459 (split-string (match-string-no-properties 1))))) 466 (split-string (match-string-no-properties 1)))))
460 (print options) 467 (print options)
461 (loop for name in alloptions 468 (loop for name in alloptions
462 collect 469 collect
463 (vector name 470 (vector name
464 `(progn 471 `(progn
465 (replace-match 472 (replace-match
466 (mapconcat 'identity 473 (mapconcat 'identity
467 (sort (if (member ',name ',options) 474 (sort (if (member ',name ',options)
468 (delete ',name ',options) 475 (delete ',name ',options)
469 (cons ',name ',options)) 476 (cons ',name ',options))
470 'string-lessp) 477 'string-lessp)
471 " ") 478 " ")
478 (if (> (length text) maxlength) 485 (if (> (length text) maxlength)
479 (concat (substring text 0 (- maxlength 3)) "...") 486 (concat (substring text 0 (- maxlength 3)) "...")
480 text)) 487 text))
481 488
482 (defun org-mouse-popup-global-menu () 489 (defun org-mouse-popup-global-menu ()
483 (popup-menu 490 (popup-menu
484 `("Main Menu" 491 `("Main Menu"
485 ["Show Overview" org-mouse-show-overview t] 492 ["Show Overview" org-mouse-show-overview t]
486 ["Show Headlines" org-mouse-show-headlines t] 493 ["Show Headlines" org-mouse-show-headlines t]
487 ["Show All" show-all t] 494 ["Show All" show-all t]
488 ["Remove Highlights" org-remove-occur-highlights 495 ["Remove Highlights" org-remove-occur-highlights
489 :visible org-occur-highlights] 496 :visible org-occur-highlights]
490 "--" 497 "--"
491 ["Check Deadlines" 498 ["Check Deadlines"
492 (if (functionp 'org-check-deadlines-and-todos) 499 (if (functionp 'org-check-deadlines-and-todos)
493 (org-check-deadlines-and-todos org-deadline-warning-days) 500 (org-check-deadlines-and-todos org-deadline-warning-days)
494 (org-check-deadlines org-deadline-warning-days)) t] 501 (org-check-deadlines org-deadline-warning-days)) t]
495 ["Check TODOs" org-show-todo-tree t] 502 ["Check TODOs" org-show-todo-tree t]
496 ("Check Tags" 503 ("Check Tags"
497 ,@(org-mouse-keyword-menu 504 ,@(org-mouse-keyword-menu
498 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp) 505 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
499 '(lambda (tag) (org-tags-sparse-tree nil tag))) 506 '(lambda (tag) (org-tags-sparse-tree nil tag)))
500 "--" 507 "--"
501 ["Custom Tag ..." org-tags-sparse-tree t]) 508 ["Custom Tag ..." org-tags-sparse-tree t])
502 ["Check Phrase ..." org-occur] 509 ["Check Phrase ..." org-occur]
503 "--" 510 "--"
504 ["Display Agenda" org-agenda-list t] 511 ["Display Agenda" org-agenda-list t]
505 ["Display Timeline" org-timeline t] 512 ["Display Timeline" org-timeline t]
506 ["Display TODO List" org-todo-list t] 513 ["Display TODO List" org-todo-list t]
507 ("Display Tags" 514 ("Display Tags"
508 ,@(org-mouse-keyword-menu 515 ,@(org-mouse-keyword-menu
509 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp) 516 (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
510 '(lambda (tag) (org-tags-view nil tag))) 517 '(lambda (tag) (org-tags-view nil tag)))
511 "--" 518 "--"
512 ["Custom Tag ..." org-tags-view t]) 519 ["Custom Tag ..." org-tags-view t])
513 ["Display Calendar" org-goto-calendar t] 520 ["Display Calendar" org-goto-calendar t]
514 "--" 521 "--"
515 ,@(org-mouse-keyword-menu 522 ,@(org-mouse-keyword-menu
516 (mapcar 'car org-agenda-custom-commands) 523 (mapcar 'car org-agenda-custom-commands)
517 '(lambda (key) 524 '(lambda (key)
518 (eval `(flet ((read-char-exclusive () (string-to-char ,key))) 525 (eval `(flet ((read-char-exclusive () (string-to-char ,key)))
519 (org-agenda nil)))) 526 (org-agenda nil))))
520 nil 527 nil
521 '(lambda (key) 528 '(lambda (key)
522 (let ((entry (assoc key org-agenda-custom-commands))) 529 (let ((entry (assoc key org-agenda-custom-commands)))
523 (org-mouse-clip-text 530 (org-mouse-clip-text
524 (cond 531 (cond
525 ((stringp (nth 1 entry)) (nth 1 entry)) 532 ((stringp (nth 1 entry)) (nth 1 entry))
526 ((stringp (nth 2 entry)) 533 ((stringp (nth 2 entry))
527 (concat (org-mouse-agenda-type (nth 1 entry)) 534 (concat (org-mouse-agenda-type (nth 1 entry))
528 (nth 2 entry))) 535 (nth 2 entry)))
529 (t "Agenda Command '%s'")) 536 (t "Agenda Command '%s'"))
530 30)))) 537 30))))
531 "--" 538 "--"
532 ["Delete Blank Lines" delete-blank-lines 539 ["Delete Blank Lines" delete-blank-lines
533 :visible (org-mouse-empty-line)] 540 :visible (org-mouse-empty-line)]
534 ["Insert Checkbox" org-mouse-insert-checkbox 541 ["Insert Checkbox" org-mouse-insert-checkbox
535 :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))] 542 :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
536 ["Insert Checkboxes" 543 ["Insert Checkboxes"
537 (org-mouse-for-each-item 'org-mouse-insert-checkbox) 544 (org-mouse-for-each-item 'org-mouse-insert-checkbox)
538 :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))] 545 :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
539 ["Plain List to Outline" org-mouse-transform-to-outline 546 ["Plain List to Outline" org-mouse-transform-to-outline
540 :visible (org-at-item-p)]))) 547 :visible (org-at-item-p)])))
541 548
542 549
543 (defun org-mouse-get-context (contextlist context) 550 (defun org-mouse-get-context (contextlist context)
544 (let ((contextdata (assq context contextlist))) 551 (let ((contextdata (assq context contextlist)))
545 (when contextdata 552 (when contextdata
546 (save-excursion 553 (save-excursion
547 (goto-char (second contextdata)) 554 (goto-char (second contextdata))
548 (re-search-forward ".*" (third contextdata)))))) 555 (re-search-forward ".*" (third contextdata))))))
549 556
550 (defun org-mouse-for-each-item (function) 557 (defun org-mouse-for-each-item (function)
551 (save-excursion 558 (save-excursion
552 (ignore-errors 559 (ignore-errors
553 (while t (org-previous-item))) 560 (while t (org-previous-item)))
554 (ignore-errors 561 (ignore-errors
555 (while t 562 (while t
556 (funcall function) 563 (funcall function)
557 (org-next-item))))) 564 (org-next-item)))))
558 565
559 (defun org-mouse-bolp () 566 (defun org-mouse-bolp ()
560 "Returns true if there only spaces, tabs, and '*', between the beginning of line and the point" 567 "Returns true if there only spaces, tabs, and '*', between the beginning of line and the point"
561 (save-excursion 568 (save-excursion
562 (skip-chars-backward " \t*") (bolp))) 569 (skip-chars-backward " \t*") (bolp)))
563 570
564 (defun org-mouse-insert-item (text) 571 (defun org-mouse-insert-item (text)
565 (case (org-mouse-line-position) 572 (case (org-mouse-line-position)
566 (:beginning ; insert before 573 (:beginning ; insert before
567 (beginning-of-line) 574 (beginning-of-line)
568 (looking-at "[ \t]*") 575 (looking-at "[ \t]*")
569 (open-line 1) 576 (open-line 1)
570 (indent-to (- (match-end 0) (match-beginning 0))) 577 (indent-to (- (match-end 0) (match-beginning 0)))
571 (insert "+ ")) 578 (insert "+ "))
572 579
573 (:middle ; insert after 580 (:middle ; insert after
574 (end-of-line) 581 (end-of-line)
575 (newline t) 582 (newline t)
576 (indent-relative) 583 (indent-relative)
577 (insert "+ ")) 584 (insert "+ "))
578 585
579 (:end ; insert text here 586 (:end ; insert text here
580 (skip-chars-backward " \t") 587 (skip-chars-backward " \t")
581 (kill-region (point) (point-at-eol)) 588 (kill-region (point) (point-at-eol))
582 (unless (looking-back org-mouse-punctuation) 589 (unless (looking-back org-mouse-punctuation)
583 (insert (concat org-mouse-punctuation " "))))) 590 (insert (concat org-mouse-punctuation " ")))))
584 591
585 (insert text) 592 (insert text)
586 (beginning-of-line)) 593 (beginning-of-line))
587 594
588 (defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate) 595 (defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
589 (if (eq major-mode 'org-mode) 596 (if (eq major-mode 'org-mode)
595 (org-mouse-insert-item uri) 602 (org-mouse-insert-item uri)
596 ad-do-it)) 603 ad-do-it))
597 604
598 (defun org-mouse-match-closure (function) 605 (defun org-mouse-match-closure (function)
599 (let ((match (match-data t))) 606 (let ((match (match-data t)))
600 `(lambda (&rest rest) 607 `(lambda (&rest rest)
601 (save-match-data 608 (save-match-data
602 (set-match-data ',match) 609 (set-match-data ',match)
603 (apply ',function rest))))) 610 (apply ',function rest)))))
604 611
605 (defun org-mouse-todo-keywords () 612 (defun org-mouse-todo-keywords ()
630 (let ((region-string (buffer-substring (region-beginning) (region-end)))) 637 (let ((region-string (buffer-substring (region-beginning) (region-end))))
631 (popup-menu 638 (popup-menu
632 `(nil 639 `(nil
633 ["Sparse Tree" (org-occur ',region-string)] 640 ["Sparse Tree" (org-occur ',region-string)]
634 ["Find in Buffer" (occur ',region-string)] 641 ["Find in Buffer" (occur ',region-string)]
635 ["Grep in Current Dir" 642 ["Grep in Current Dir"
636 (grep (format "grep -rnH -e '%s' *" ',region-string))] 643 (grep (format "grep -rnH -e '%s' *" ',region-string))]
637 ["Grep in Parent Dir" 644 ["Grep in Parent Dir"
638 (grep (format "grep -rnH -e '%s' ../*" ',region-string))] 645 (grep (format "grep -rnH -e '%s' ../*" ',region-string))]
639 "--" 646 "--"
640 ["Convert to Link" 647 ["Convert to Link"
641 (progn (save-excursion (goto-char (region-beginning)) (insert "[[")) 648 (progn (save-excursion (goto-char (region-beginning)) (insert "[["))
642 (save-excursion (goto-char (region-end)) (insert "]]")))] 649 (save-excursion (goto-char (region-end)) (insert "]]")))]
643 ["Insert Link Here" (org-mouse-yank-link ',event)])))) 650 ["Insert Link Here" (org-mouse-yank-link ',event)]))))
644 651
645 ((save-excursion (beginning-of-line) (looking-at "#\\+STARTUP: \\(.*\\)")) 652 ((save-excursion (beginning-of-line) (looking-at "#\\+STARTUP: \\(.*\\)"))
646 (popup-menu 653 (popup-menu
647 `(nil 654 `(nil
648 ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options) 655 ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
649 'org-mode-restart)))) 656 'org-mode-restart))))
650 ((or (eolp) 657 ((or (eolp)
651 (and (looking-at "\\( \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\( \\|\t\\)+$") 658 (and (looking-at "\\( \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\( \\|\t\\)+$")
652 (looking-back " \\|\t"))) 659 (looking-back " \\|\t")))
653 (org-mouse-popup-global-menu)) 660 (org-mouse-popup-global-menu))
654 ((get-context :checkbox) 661 ((get-context :checkbox)
655 (popup-menu 662 (popup-menu
656 '(nil 663 '(nil
657 ["Toggle" org-toggle-checkbox t] 664 ["Toggle" org-toggle-checkbox t]
658 ["Remove" org-mouse-remove-match-and-spaces t] 665 ["Remove" org-mouse-remove-match-and-spaces t]
659 "" 666 ""
660 ["All Clear" (org-mouse-for-each-item 667 ["All Clear" (org-mouse-for-each-item
661 (lambda () 668 (lambda ()
671 (when (save-excursion (org-at-item-checkbox-p)) 678 (when (save-excursion (org-at-item-checkbox-p))
672 (org-mouse-remove-match-and-spaces))))] 679 (org-mouse-remove-match-and-spaces))))]
673 ))) 680 )))
674 ((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_") 681 ((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_")
675 (member (match-string 0) (org-mouse-todo-keywords))) 682 (member (match-string 0) (org-mouse-todo-keywords)))
676 (popup-menu 683 (popup-menu
677 `(nil 684 `(nil
678 ,@(org-mouse-keyword-replace-menu (org-mouse-todo-keywords)) 685 ,@(org-mouse-keyword-replace-menu (org-mouse-todo-keywords))
679 "--" 686 "--"
680 ["Check TODOs" org-show-todo-tree t] 687 ["Check TODOs" org-show-todo-tree t]
681 ["List all TODO keywords" org-todo-list t] 688 ["List all TODO keywords" org-todo-list t]
682 [,(format "List only %s" (match-string 0)) 689 [,(format "List only %s" (match-string 0))
683 (org-todo-list (match-string 0)) t] 690 (org-todo-list (match-string 0)) t]
684 ))) 691 )))
685 ((and (org-mouse-looking-at "\\b[A-Z]+:" "A-Z") 692 ((and (org-mouse-looking-at "\\b[A-Z]+:" "A-Z")
686 (member (match-string 0) stamp-prefixes)) 693 (member (match-string 0) stamp-prefixes))
687 (popup-menu 694 (popup-menu
688 `(nil 695 `(nil
689 ,@(org-mouse-keyword-replace-menu stamp-prefixes) 696 ,@(org-mouse-keyword-replace-menu stamp-prefixes)
690 "--" 697 "--"
691 ["Check Deadlines" org-check-deadlines t] 698 ["Check Deadlines" org-check-deadlines t]
692 ))) 699 )))
693 ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority 700 ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority
694 (popup-menu `(nil ,@(org-mouse-keyword-replace-menu 701 (popup-menu `(nil ,@(org-mouse-keyword-replace-menu
695 (org-mouse-priority-list) 1 "Priority %s" t)))) 702 (org-mouse-priority-list) 1 "Priority %s" t))))
696 ((get-context :link) 703 ((get-context :link)
697 (popup-menu 704 (popup-menu
698 '(nil 705 '(nil
699 ["Open" org-open-at-point t] 706 ["Open" org-open-at-point t]
700 ["Open in Emacs" (org-open-at-point t) t] 707 ["Open in Emacs" (org-open-at-point t) t]
701 "--" 708 "--"
702 ["Copy link" (kill-new (match-string 0))] 709 ["Copy link" (kill-new (match-string 0))]
703 ["Cut link" 710 ["Cut link"
704 (progn 711 (progn
705 (kill-region (match-beginning 0) (match-end 0)) 712 (kill-region (match-beginning 0) (match-end 0))
706 (just-one-space))] 713 (just-one-space))]
707 "--" 714 "--"
708 ["Grep for TODOs" 715 ["Grep for TODOs"
709 (grep (format "grep -nH -i 'todo\\|fixme' %s*" (match-string 2)))] 716 (grep (format "grep -nH -i 'todo\\|fixme' %s*" (match-string 2)))]
710 ; ["Paste file link" ((insert "file:") (yank))] 717 ; ["Paste file link" ((insert "file:") (yank))]
711 ))) 718 )))
712 ((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags 719 ((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags
713 (popup-menu 720 (popup-menu
714 `(nil 721 `(nil
715 [,(format "Display '%s'" (match-string 1)) 722 [,(format "Display '%s'" (match-string 1))
716 (org-tags-view nil ,(match-string 1))] 723 (org-tags-view nil ,(match-string 1))]
717 [,(format "Sparse Tree '%s'" (match-string 1)) 724 [,(format "Sparse Tree '%s'" (match-string 1))
718 (org-tags-sparse-tree nil ,(match-string 1))] 725 (org-tags-sparse-tree nil ,(match-string 1))]
719 "--" 726 "--"
720 ,@(org-mouse-tag-menu)))) 727 ,@(org-mouse-tag-menu))))
721 ((org-at-timestamp-p) 728 ((org-at-timestamp-p)
722 (popup-menu 729 (popup-menu
723 '(nil 730 '(nil
724 ["Show Day" org-open-at-point t] 731 ["Show Day" org-open-at-point t]
725 ["Change Timestamp" org-time-stamp t] 732 ["Change Timestamp" org-time-stamp t]
726 ["Delete Timestamp" (org-mouse-delete-timestamp) t] 733 ["Delete Timestamp" (org-mouse-delete-timestamp) t]
727 ["Compute Time Range" org-evaluate-time-range (org-at-date-range-p)] 734 ["Compute Time Range" org-evaluate-time-range (org-at-date-range-p)]
742 ((get-context :table-special) 749 ((get-context :table-special)
743 (let ((mdata (match-data))) 750 (let ((mdata (match-data)))
744 (incf (car mdata) 2) 751 (incf (car mdata) 2)
745 (store-match-data mdata)) 752 (store-match-data mdata))
746 (message "match: %S" (match-string 0)) 753 (message "match: %S" (match-string 0))
747 (popup-menu `(nil ,@(org-mouse-keyword-replace-menu 754 (popup-menu `(nil ,@(org-mouse-keyword-replace-menu
748 '(" " "!" "^" "_" "$" "#" "*" "'") 0 755 '(" " "!" "^" "_" "$" "#" "*" "'") 0
749 (lambda (mark) 756 (lambda (mark)
750 (case (string-to-char mark) 757 (case (string-to-char mark)
751 (? "( ) Nothing Special") 758 (? "( ) Nothing Special")
752 (?! "(!) Column Names") 759 (?! "(!) Column Names")
753 (?^ "(^) Field Names Above") 760 (?^ "(^) Field Names Above")
802 ))) 809 )))
803 ((and (assq :headline contextlist) (not (eolp))) 810 ((and (assq :headline contextlist) (not (eolp)))
804 (let ((priority (org-mouse-get-priority t))) 811 (let ((priority (org-mouse-get-priority t)))
805 (popup-menu 812 (popup-menu
806 `("Headline Menu" 813 `("Headline Menu"
807 ("Tags and Priorities" 814 ("Tags and Priorities"
808 ,@(org-mouse-keyword-menu 815 ,@(org-mouse-keyword-menu
809 (org-mouse-priority-list) 816 (org-mouse-priority-list)
810 '(lambda (keyword) 817 '(lambda (keyword)
811 (org-mouse-set-priority (string-to-char keyword))) 818 (org-mouse-set-priority (string-to-char keyword)))
812 priority "Priority %s") 819 priority "Priority %s")
813 "--" 820 "--"
814 ,@(org-mouse-tag-menu)) 821 ,@(org-mouse-tag-menu))
815 ("TODO Status" 822 ("TODO Status"
816 ,@(progn (org-mouse-match-todo-keyword) 823 ,@(progn (org-mouse-match-todo-keyword)
817 (org-mouse-keyword-replace-menu (org-mouse-todo-keywords) 824 (org-mouse-keyword-replace-menu (org-mouse-todo-keywords)
818 1))) 825 1)))
819 ["Show Tags" 826 ["Show Tags"
820 (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags)) 827 (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
821 :visible (not org-mouse-direct)] 828 :visible (not org-mouse-direct)]
822 ["Show Priority" 829 ["Show Priority"
823 (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority)) 830 (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority))
824 :visible (not org-mouse-direct)] 831 :visible (not org-mouse-direct)]
825 ,@(if org-mouse-direct '("--") nil) 832 ,@(if org-mouse-direct '("--") nil)
826 ["New Heading" org-mouse-insert-heading :visible org-mouse-direct] 833 ["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
827 ["Set Deadline" 834 ["Set Deadline"
828 (progn (org-mouse-end-headline) (insert " ") (org-deadline)) 835 (progn (org-mouse-end-headline) (insert " ") (org-deadline))
829 :active (not (save-excursion 836 :active (not (save-excursion
830 (org-mouse-re-search-line org-deadline-regexp)))] 837 (org-mouse-re-search-line org-deadline-regexp)))]
831 ["Schedule Task" 838 ["Schedule Task"
832 (progn (org-mouse-end-headline) (insert " ") (org-schedule)) 839 (progn (org-mouse-end-headline) (insert " ") (org-schedule))
833 :active (not (save-excursion 840 :active (not (save-excursion
834 (org-mouse-re-search-line org-scheduled-regexp)))] 841 (org-mouse-re-search-line org-scheduled-regexp)))]
835 ["Insert Timestamp" 842 ["Insert Timestamp"
836 (progn (org-mouse-end-headline) (insert " ") (org-time-stamp nil)) t] 843 (progn (org-mouse-end-headline) (insert " ") (org-time-stamp nil)) t]
837 ; ["Timestamp (inactive)" org-time-stamp-inactive t] 844 ; ["Timestamp (inactive)" org-time-stamp-inactive t]
838 "--" 845 "--"
839 ["Archive Subtree" org-archive-subtree] 846 ["Archive Subtree" org-archive-subtree]
840 ["Cut Subtree" org-cut-special] 847 ["Cut Subtree" org-cut-special]
841 ["Copy Subtree" org-copy-special] 848 ["Copy Subtree" org-copy-special]
842 ["Paste Subtree" org-paste-special :visible org-mouse-direct] 849 ["Paste Subtree" org-paste-special :visible org-mouse-direct]
843 ("Sort Children" 850 ("Sort Children"
844 ["Alphabetically" (org-sort-entries nil ?a)] 851 ["Alphabetically" (org-sort-entries nil ?a)]
845 ["Numerically" (org-sort-entries nil ?n)] 852 ["Numerically" (org-sort-entries nil ?n)]
846 ["By Time/Date" (org-sort-entries nil ?t)] 853 ["By Time/Date" (org-sort-entries nil ?t)]
847 "--" 854 "--"
848 ["Reverse Alphabetically" (org-sort-entries nil ?A)] 855 ["Reverse Alphabetically" (org-sort-entries nil ?A)]
849 ["Reverse Numerically" (org-sort-entries nil ?N)] 856 ["Reverse Numerically" (org-sort-entries nil ?N)]
850 ["Reverse By Time/Date" (org-sort-entries nil ?T)]) 857 ["Reverse By Time/Date" (org-sort-entries nil ?T)])
851 "--" 858 "--"
852 ["Move Trees" org-mouse-move-tree :active nil] 859 ["Move Trees" org-mouse-move-tree :active nil]
853 )))) 860 ))))
854 (t 861 (t
855 (org-mouse-popup-global-menu)))))) 862 (org-mouse-popup-global-menu))))))
856 863
857 ;; (defun org-mouse-at-regexp (regexp) 864 ;; (defun org-mouse-at-regexp (regexp)
858 ;; (save-excursion 865 ;; (save-excursion
859 ;; (let ((point (point)) 866 ;; (let ((point (point))
868 875
869 (defun org-mouse-mark-active () 876 (defun org-mouse-mark-active ()
870 (and mark-active transient-mark-mode)) 877 (and mark-active transient-mark-mode))
871 878
872 (defun org-mouse-in-region-p (pos) 879 (defun org-mouse-in-region-p (pos)
873 (and (org-mouse-mark-active) 880 (and (org-mouse-mark-active)
874 (>= pos (region-beginning)) 881 (>= pos (region-beginning))
875 (< pos (region-end)))) 882 (< pos (region-end))))
876 883
877 (defun org-mouse-down-mouse (event) 884 (defun org-mouse-down-mouse (event)
878 (interactive "e") 885 (interactive "e")
879 (setq this-command last-command) 886 (setq this-command last-command)
894 (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link) 901 (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link)
895 (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link) 902 (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link)
896 (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree) 903 (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree)
897 (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start) 904 (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start)
898 905
899 (font-lock-add-keywords nil 906 (font-lock-add-keywords nil
900 `((,outline-regexp 907 `((,outline-regexp
901 0 `(face org-link mouse-face highlight keymap ,org-mouse-map) 908 0 `(face org-link mouse-face highlight keymap ,org-mouse-map)
902 'prepend) 909 'prepend)
903 ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +" 910 ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +"
904 (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) 'prepend)) 911 (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) 'prepend))
905 ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)" 912 ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
906 (2 `(face bold keymap ,org-mouse-map mouse-face highlight) t))) 913 (2 `(face bold keymap ,org-mouse-map mouse-face highlight) t)))
907 t) 914 t)
908 915
909 (defadvice org-open-at-point (around org-mouse-open-at-point activate) 916 (defadvice org-open-at-point (around org-mouse-open-at-point activate)
910 (let ((context (org-context))) 917 (let ((context (org-context)))
911 (cond 918 (cond
912 ((assq :headline-stars context) (org-cycle)) 919 ((assq :headline-stars context) (org-cycle))
913 ((assq :checkbox context) (org-toggle-checkbox)) 920 ((assq :checkbox context) (org-toggle-checkbox))
914 ((assq :item-bullet context) 921 ((assq :item-bullet context)
915 (let ((org-cycle-include-plain-lists t)) (org-cycle))) 922 (let ((org-cycle-include-plain-lists t)) (org-cycle)))
916 (t ad-do-it)))))) 923 (t ad-do-it))))))
936 (when (and sbuf ebuf) 943 (when (and sbuf ebuf)
937 (set-buffer sbuf) 944 (set-buffer sbuf)
938 (goto-char start) 945 (goto-char start)
939 (org-back-to-heading) 946 (org-back-to-heading)
940 (if (and (eq sbuf ebuf) 947 (if (and (eq sbuf ebuf)
941 (equal 948 (equal
942 (point) 949 (point)
943 (save-excursion (goto-char end) (org-back-to-heading) (point)))) 950 (save-excursion (goto-char end) (org-back-to-heading) (point))))
944 ;; if the same line then promote/demote 951 ;; if the same line then promote/demote
945 (if (>= end start) (org-demote-subtree) (org-promote-subtree)) 952 (if (>= end start) (org-demote-subtree) (org-promote-subtree))
946 ;; if different lines then move 953 ;; if different lines then move
947 (org-cut-subtree) 954 (org-cut-subtree)
948 955
949 (set-buffer ebuf) 956 (set-buffer ebuf)
950 (goto-char end) 957 (goto-char end)
951 (org-back-to-heading) 958 (org-back-to-heading)
952 (when (and (eq sbuf ebuf) 959 (when (and (eq sbuf ebuf)
953 (equal 960 (equal
954 (point) 961 (point)
955 (save-excursion (goto-char start) 962 (save-excursion (goto-char start)
956 (org-back-to-heading) (point)))) 963 (org-back-to-heading) (point))))
957 (outline-end-of-subtree) 964 (outline-end-of-subtree)
958 (end-of-line) 965 (end-of-line)
959 (if (eobp) (newline) (forward-char))) 966 (if (eobp) (newline) (forward-char)))
960 967
961 (when (looking-at outline-regexp) 968 (when (looking-at outline-regexp)
962 (let ((level (- (match-end 0) (match-beginning 0)))) 969 (let ((level (- (match-end 0) (match-beginning 0))))
963 (when (> end (match-end 0)) 970 (when (> end (match-end 0))
964 (outline-end-of-subtree) 971 (outline-end-of-subtree)
965 (end-of-line) 972 (end-of-line)
1001 (buffer-read-only nil) 1008 (buffer-read-only nil)
1002 (newhead "--- removed ---") 1009 (newhead "--- removed ---")
1003 (org-mouse-direct nil) 1010 (org-mouse-direct nil)
1004 (org-mouse-main-buffer (current-buffer))) 1011 (org-mouse-main-buffer (current-buffer)))
1005 (when (eq (with-current-buffer buffer major-mode) 'org-mode) 1012 (when (eq (with-current-buffer buffer major-mode) 'org-mode)
1006 (let ((endmarker (save-excursion 1013 (let ((endmarker (save-excursion
1007 (set-buffer buffer) 1014 (set-buffer buffer)
1008 (outline-end-of-subtree) 1015 (outline-end-of-subtree)
1009 (forward-char 1) 1016 (forward-char 1)
1010 (copy-marker (point))))) 1017 (copy-marker (point)))))
1011 (org-with-remote-undo buffer 1018 (org-with-remote-undo buffer
1012 (with-current-buffer buffer 1019 (with-current-buffer buffer
1013 (widen) 1020 (widen)
1022 (funcall command) 1029 (funcall command)
1023 (message "_cmd: %S" _cmd) 1030 (message "_cmd: %S" _cmd)
1024 (message "this-command: %S" this-command) 1031 (message "this-command: %S" this-command)
1025 (unless (eq (marker-position marker) (marker-position endmarker)) 1032 (unless (eq (marker-position marker) (marker-position endmarker))
1026 (setq newhead (org-get-heading)))) 1033 (setq newhead (org-get-heading))))
1027 1034
1028 (beginning-of-line 1) 1035 (beginning-of-line 1)
1029 (save-excursion 1036 (save-excursion
1030 (org-agenda-change-all-lines newhead hdmarker 'fixface)))) 1037 (org-agenda-change-all-lines newhead hdmarker 'fixface))))
1031 t)))) 1038 t))))
1032 1039
1033 (defun org-mouse-agenda-context-menu (&optional event) 1040 (defun org-mouse-agenda-context-menu (&optional event)
1034 (or (org-mouse-do-remotely 'org-mouse-context-menu) 1041 (or (org-mouse-do-remotely 'org-mouse-context-menu)
1035 (popup-menu 1042 (popup-menu
1036 '("Agenda" 1043 '("Agenda"
1037 ("Agenda Files") 1044 ("Agenda Files")
1038 "--" 1045 "--"
1039 ["Undo" (progn (message "last command: %S" last-command) (setq this-command 'org-agenda-undo) (org-agenda-undo)) 1046 ["Undo" (progn (message "last command: %S" last-command) (setq this-command 'org-agenda-undo) (org-agenda-undo))
1040 :visible (if (eq last-command 'org-agenda-undo) 1047 :visible (if (eq last-command 'org-agenda-undo)
1041 org-agenda-pending-undo-list 1048 org-agenda-pending-undo-list
1042 org-agenda-undo-list)] 1049 org-agenda-undo-list)]
1043 ["Rebuild Buffer" org-agenda-redo t] 1050 ["Rebuild Buffer" org-agenda-redo t]
1044 ["New Diary Entry" 1051 ["New Diary Entry"
1045 org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline) t] 1052 org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline) t]
1046 "--" 1053 "--"
1047 ["Goto Today" org-agenda-goto-today 1054 ["Goto Today" org-agenda-goto-today
1048 (org-agenda-check-type nil 'agenda 'timeline) t] 1055 (org-agenda-check-type nil 'agenda 'timeline) t]
1049 ["Display Calendar" org-agenda-goto-calendar 1056 ["Display Calendar" org-agenda-goto-calendar
1050 (org-agenda-check-type nil 'agenda 'timeline) t] 1057 (org-agenda-check-type nil 'agenda 'timeline) t]
1051 ("Calendar Commands" 1058 ("Calendar Commands"
1052 ["Phases of the Moon" org-agenda-phases-of-moon 1059 ["Phases of the Moon" org-agenda-phases-of-moon
1053 (org-agenda-check-type nil 'agenda 'timeline)] 1060 (org-agenda-check-type nil 'agenda 'timeline)]
1054 ["Sunrise/Sunset" org-agenda-sunrise-sunset 1061 ["Sunrise/Sunset" org-agenda-sunrise-sunset
1055 (org-agenda-check-type nil 'agenda 'timeline)] 1062 (org-agenda-check-type nil 'agenda 'timeline)]
1056 ["Holidays" org-agenda-holidays 1063 ["Holidays" org-agenda-holidays
1057 (org-agenda-check-type nil 'agenda 'timeline)] 1064 (org-agenda-check-type nil 'agenda 'timeline)]
1058 ["Convert" org-agenda-convert-date 1065 ["Convert" org-agenda-convert-date
1059 (org-agenda-check-type nil 'agenda 'timeline)] 1066 (org-agenda-check-type nil 'agenda 'timeline)]
1060 "--" 1067 "--"
1061 ["Create iCalendar file" org-export-icalendar-combine-agenda-files t]) 1068 ["Create iCalendar file" org-export-icalendar-combine-agenda-files t])
1062 "--" 1069 "--"
1063 ["Day View" org-agenda-day-view 1070 ["Day View" org-agenda-day-view
1064 :active (org-agenda-check-type nil 'agenda) 1071 :active (org-agenda-check-type nil 'agenda)
1065 :style radio :selected (equal org-agenda-ndays 1)] 1072 :style radio :selected (equal org-agenda-ndays 1)]
1066 ["Week View" org-agenda-week-view 1073 ["Week View" org-agenda-week-view
1067 :active (org-agenda-check-type nil 'agenda) 1074 :active (org-agenda-check-type nil 'agenda)
1068 :style radio :selected (equal org-agenda-ndays 7)] 1075 :style radio :selected (equal org-agenda-ndays 7)]
1069 "--" 1076 "--"
1070 ["Show Logbook entries" org-agenda-log-mode 1077 ["Show Logbook entries" org-agenda-log-mode
1071 :style toggle :selected org-agenda-show-log 1078 :style toggle :selected org-agenda-show-log
1072 :active (org-agenda-check-type nil 'agenda 'timeline)] 1079 :active (org-agenda-check-type nil 'agenda 'timeline)]
1073 ["Include Diary" org-agenda-toggle-diary 1080 ["Include Diary" org-agenda-toggle-diary
1074 :style toggle :selected org-agenda-include-diary 1081 :style toggle :selected org-agenda-include-diary
1075 :active (org-agenda-check-type nil 'agenda)] 1082 :active (org-agenda-check-type nil 'agenda)]
1076 ["Use Time Grid" org-agenda-toggle-time-grid 1083 ["Use Time Grid" org-agenda-toggle-time-grid
1077 :style toggle :selected org-agenda-use-time-grid 1084 :style toggle :selected org-agenda-use-time-grid
1078 :active (org-agenda-check-type nil 'agenda)] 1085 :active (org-agenda-check-type nil 'agenda)]
1079 ["Follow Mode" org-agenda-follow-mode 1086 ["Follow Mode" org-agenda-follow-mode
1088 (endxy (posn-x-y (event-end event)))) 1095 (endxy (posn-x-y (event-end event))))
1089 (if (< (car startxy) (car endxy)) :right :left))) 1096 (if (< (car startxy) (car endxy)) :right :left)))
1090 1097
1091 1098
1092 ; (setq org-agenda-mode-hook nil) 1099 ; (setq org-agenda-mode-hook nil)
1093 (add-hook 'org-agenda-mode-hook 1100 (add-hook 'org-agenda-mode-hook
1094 '(lambda () 1101 '(lambda ()
1095 (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu) 1102 (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu)
1096 (define-key org-agenda-keymap 1103 (define-key org-agenda-keymap
1097 (if (featurep 'xemacs) [button3] [mouse-3]) 1104 (if (featurep 'xemacs) [button3] [mouse-3])
1098 'org-mouse-show-context-menu) 1105 'org-mouse-show-context-menu)
1099 (define-key org-agenda-keymap [down-mouse-3] 'org-mouse-move-tree-start) 1106 (define-key org-agenda-keymap [down-mouse-3] 'org-mouse-move-tree-start)
1100 (define-key org-agenda-keymap [C-mouse-4] 'org-agenda-earlier) 1107 (define-key org-agenda-keymap [C-mouse-4] 'org-agenda-earlier)
1101 (define-key org-agenda-keymap [C-mouse-5] 'org-agenda-later) 1108 (define-key org-agenda-keymap [C-mouse-5] 'org-agenda-later)
1102 (define-key org-agenda-keymap [drag-mouse-3] 1109 (define-key org-agenda-keymap [drag-mouse-3]