2016-06-21 21:12:23 +00:00
|
|
|
;;; org-mouse.el --- Better mouse support for Org -*- lexical-binding: t; -*-
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2021-01-01 19:55:31 +00:00
|
|
|
;; Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
2012-01-05 08:43:21 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
|
2008-01-31 10:36:18 +00:00
|
|
|
;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
|
2011-08-17 12:42:34 +00:00
|
|
|
|
2008-01-31 10:36:18 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
2012-01-05 08:43:21 +00:00
|
|
|
|
2008-05-06 12:45:52 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2008-01-31 10:36:18 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 12:45:52 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2008-01-31 10:36:18 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2008-01-31 10:36:18 +00:00
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2012-01-05 08:43:21 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
;;; Commentary:
|
|
|
|
;;
|
2008-01-31 10:36:18 +00:00
|
|
|
;; Org-mouse provides mouse support for org-mode.
|
2008-01-31 10:32:52 +00:00
|
|
|
;;
|
2018-01-16 16:22:00 +00:00
|
|
|
;; https://orgmode.org
|
2008-01-31 10:32:52 +00:00
|
|
|
;;
|
2016-06-26 12:35:22 +00:00
|
|
|
;; Org mouse implements the following features:
|
|
|
|
;; * following links with the left mouse button
|
2008-01-31 10:32:52 +00:00
|
|
|
;; * subtree expansion/collapse (org-cycle) with the left mouse button
|
|
|
|
;; * several context menus on the right mouse button:
|
|
|
|
;; + general text
|
|
|
|
;; + headlines
|
|
|
|
;; + timestamps
|
|
|
|
;; + priorities
|
|
|
|
;; + links
|
|
|
|
;; + tags
|
|
|
|
;; * promoting/demoting/moving subtrees with mouse-3
|
|
|
|
;; + if the drag starts and ends in the same line then promote/demote
|
2008-04-24 08:29:47 +00:00
|
|
|
;; + otherwise move the subtree
|
2008-01-31 10:32:52 +00:00
|
|
|
;;
|
|
|
|
;; Use
|
2008-01-31 10:36:18 +00:00
|
|
|
;; ---
|
2008-01-31 10:32:52 +00:00
|
|
|
;;
|
|
|
|
;; To use this package, put the following line in your .emacs:
|
|
|
|
;;
|
|
|
|
;; (require 'org-mouse)
|
|
|
|
;;
|
|
|
|
|
2008-12-16 16:25:37 +00:00
|
|
|
;; FIXME:
|
2008-01-31 10:32:52 +00:00
|
|
|
;; + deal with folding / unfolding issues
|
|
|
|
|
|
|
|
;; TODO (This list is only theoretical, if you'd like to have some
|
|
|
|
;; feature implemented or a bug fix please send me an email, even if
|
|
|
|
;; something similar appears in the list below. This will help me get
|
|
|
|
;; the priorities right.):
|
2008-01-31 10:33:13 +00:00
|
|
|
;;
|
2008-01-31 10:32:52 +00:00
|
|
|
;; + org-store-link, insert link
|
|
|
|
;; + org tables
|
|
|
|
;; + occur with the current word/tag (same menu item)
|
|
|
|
;; + ctrl-c ctrl-c, for example, renumber the current list
|
|
|
|
;; + internal links
|
|
|
|
|
2008-01-31 10:36:18 +00:00
|
|
|
;; Please email the maintainer with new feature suggestions / bugs
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
;; History:
|
|
|
|
;;
|
2016-08-23 20:13:56 +00:00
|
|
|
;; Since version 5.10: Changes are listed in the general Org docs.
|
2008-01-31 10:36:18 +00:00
|
|
|
;;
|
2016-10-11 16:00:08 +00:00
|
|
|
;; Version 5.09;; + Version number synchronization with Org mode.
|
2008-01-31 10:36:18 +00:00
|
|
|
;;
|
|
|
|
;; Version 0.25
|
2016-08-23 20:13:56 +00:00
|
|
|
;; + made compatible with Org 4.70 (thanks to Carsten for the patch)
|
2008-01-31 10:36:18 +00:00
|
|
|
;;
|
2008-01-31 10:33:55 +00:00
|
|
|
;; Version 0.24
|
|
|
|
;; + minor changes to the table menu
|
|
|
|
;;
|
2008-01-31 10:33:46 +00:00
|
|
|
;; Version 0.23
|
|
|
|
;; + preliminary support for tables and calculation marks
|
|
|
|
;; + context menu support for org-agenda-undo & org-sort-entries
|
|
|
|
;;
|
|
|
|
;; Version 0.22
|
2016-08-23 20:13:56 +00:00
|
|
|
;; + handles undo support for the agenda buffer (requires Org >=4.58)
|
2008-01-31 10:33:46 +00:00
|
|
|
;;
|
2008-01-31 10:33:13 +00:00
|
|
|
;; Version 0.21
|
|
|
|
;; + selected text activates its context menu
|
|
|
|
;; + shift-middleclick or right-drag inserts the text from the clipboard in the form of a link
|
|
|
|
;;
|
|
|
|
;; Version 0.20
|
2008-04-24 08:29:47 +00:00
|
|
|
;; + the new "TODO Status" submenu replaces the "Cycle TODO" menu item
|
2008-01-31 10:33:13 +00:00
|
|
|
;; + the TODO menu can now list occurrences of a specific TODO keyword
|
|
|
|
;; + #+STARTUP line is now recognized
|
|
|
|
;;
|
2008-01-31 10:32:52 +00:00
|
|
|
;; Version 0.19
|
|
|
|
;; + added support for dragging URLs to the org-buffer
|
|
|
|
;;
|
|
|
|
;; Version 0.18
|
|
|
|
;; + added support for agenda blocks
|
|
|
|
;;
|
|
|
|
;; Version 0.17
|
|
|
|
;; + toggle checkboxes with a single click
|
|
|
|
;;
|
|
|
|
;; Version 0.16
|
|
|
|
;; + added support for checkboxes
|
|
|
|
;;
|
|
|
|
;; Version 0.15
|
2016-08-23 20:13:56 +00:00
|
|
|
;; + Org now works with the Agenda buffer as well
|
2008-01-31 10:32:52 +00:00
|
|
|
;;
|
|
|
|
;; Version 0.14
|
|
|
|
;; + added a menu option that converts plain list items to outline items
|
|
|
|
;;
|
2008-04-24 08:29:47 +00:00
|
|
|
;; Version 0.13
|
2008-01-31 10:32:52 +00:00
|
|
|
;; + "Insert Heading" now inserts a sibling heading if the point is
|
|
|
|
;; on "***" and a child heading otherwise
|
2008-04-24 08:29:47 +00:00
|
|
|
;;
|
2008-01-31 10:32:52 +00:00
|
|
|
;; Version 0.12
|
|
|
|
;; + compatible with Emacs 21
|
|
|
|
;; + custom agenda commands added to the main menu
|
|
|
|
;; + moving trees should now work between windows in the same frame
|
|
|
|
;;
|
|
|
|
;; Version 0.11
|
|
|
|
;; + fixed org-mouse-at-link (thanks to Carsten)
|
|
|
|
;; + removed [follow-link] bindings
|
|
|
|
;;
|
|
|
|
;; Version 0.10
|
|
|
|
;; + added a menu option to remove highlights
|
2016-08-23 20:13:56 +00:00
|
|
|
;; + compatible with Org 4.21 now
|
2008-01-31 10:32:52 +00:00
|
|
|
;;
|
2008-04-24 08:29:47 +00:00
|
|
|
;; Version 0.08:
|
2008-01-31 10:32:52 +00:00
|
|
|
;; + trees can be moved/promoted/demoted by dragging with the right
|
|
|
|
;; mouse button (mouse-3)
|
|
|
|
;; + small changes in the above function
|
|
|
|
;;
|
|
|
|
;; Versions 0.01 -- 0.07: (I don't remember)
|
|
|
|
|
2010-07-16 21:23:01 +00:00
|
|
|
;;; Code:
|
|
|
|
|
2008-01-31 10:36:18 +00:00
|
|
|
(require 'org)
|
2016-07-25 13:46:09 +00:00
|
|
|
(require 'cl-lib)
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2008-03-22 15:52:18 +00:00
|
|
|
(defvar org-agenda-allow-remote-undo)
|
|
|
|
(defvar org-agenda-undo-list)
|
|
|
|
(defvar org-agenda-custom-commands)
|
|
|
|
(declare-function org-agenda-change-all-lines "org-agenda"
|
2008-11-24 11:21:40 +00:00
|
|
|
(newhead hdmarker &optional fixface just-this))
|
2008-03-22 15:52:18 +00:00
|
|
|
(declare-function org-verify-change-for-undo "org-agenda" (l1 l2))
|
2010-09-12 11:15:48 +00:00
|
|
|
(declare-function org-apply-on-list "org-list" (function init-value &rest args))
|
2011-06-14 19:51:13 +00:00
|
|
|
(declare-function org-agenda-earlier "org-agenda" (arg))
|
|
|
|
(declare-function org-agenda-later "org-agenda" (arg))
|
2008-03-22 15:52:18 +00:00
|
|
|
|
2016-06-21 21:12:23 +00:00
|
|
|
(defvar org-mouse-main-buffer nil
|
|
|
|
"Active buffer for mouse operations.")
|
2008-01-31 10:36:18 +00:00
|
|
|
(defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
|
|
|
|
"Regular expression that matches a plain list.")
|
|
|
|
(defvar org-mouse-direct t
|
|
|
|
"Internal variable indicating whether the current action is direct.
|
|
|
|
|
|
|
|
If t, then the current action has been invoked directly through the buffer
|
|
|
|
it is intended to operate on. If nil, then the action has been invoked
|
|
|
|
indirectly, for example, through the agenda buffer.")
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defgroup org-mouse nil
|
2008-01-31 10:36:18 +00:00
|
|
|
"Mouse support for org-mode."
|
|
|
|
:tag "Org Mouse"
|
2008-01-31 10:32:52 +00:00
|
|
|
:group 'org)
|
|
|
|
|
|
|
|
(defcustom org-mouse-punctuation ":"
|
2008-01-31 10:36:18 +00:00
|
|
|
"Punctuation used when inserting text by drag and drop."
|
2008-01-31 10:32:52 +00:00
|
|
|
:group 'org-mouse
|
|
|
|
:type 'string)
|
|
|
|
|
2008-10-22 07:41:15 +00:00
|
|
|
(defcustom org-mouse-features
|
|
|
|
'(context-menu yank-link activate-stars activate-bullets activate-checkboxes)
|
|
|
|
"The features of org-mouse that should be activated.
|
|
|
|
Changing this variable requires a restart of Emacs to get activated."
|
|
|
|
:group 'org-mouse
|
|
|
|
:type '(set :greedy t
|
|
|
|
(const :tag "Mouse-3 shows context menu" context-menu)
|
|
|
|
(const :tag "C-mouse-1 and mouse-3 move trees" move-tree)
|
|
|
|
(const :tag "S-mouse-2 and drag-mouse-3 yank link" yank-link)
|
|
|
|
(const :tag "Activate headline stars" activate-stars)
|
|
|
|
(const :tag "Activate item bullets" activate-bullets)
|
2008-12-04 14:33:43 +00:00
|
|
|
(const :tag "Activate checkboxes" activate-checkboxes)))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defun org-mouse-re-search-line (regexp)
|
2008-01-31 10:36:18 +00:00
|
|
|
"Search the current line for a given regular expression."
|
2008-01-31 10:32:52 +00:00
|
|
|
(beginning-of-line)
|
|
|
|
(re-search-forward regexp (point-at-eol) t))
|
|
|
|
|
|
|
|
(defun org-mouse-end-headline ()
|
|
|
|
"Go to the end of current headline (ignoring tags)."
|
|
|
|
(interactive)
|
|
|
|
(end-of-line)
|
|
|
|
(skip-chars-backward "\t ")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
(when (looking-back ":[A-Za-z]+:" (line-beginning-position))
|
2008-01-31 10:32:52 +00:00
|
|
|
(skip-chars-backward ":A-Za-z")
|
|
|
|
(skip-chars-backward "\t ")))
|
|
|
|
|
2015-11-05 16:47:38 +00:00
|
|
|
(defvar-local org-mouse-context-menu-function nil
|
2008-01-31 10:36:18 +00:00
|
|
|
"Function to create the context menu.
|
|
|
|
The value of this variable is the function invoked by
|
|
|
|
`org-mouse-context-menu' as the context menu.")
|
2008-01-31 10:33:13 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-show-context-menu (event prefix)
|
2008-01-31 10:36:18 +00:00
|
|
|
"Invoke the context menu.
|
|
|
|
|
|
|
|
If the value of `org-mouse-context-menu-function' is a function, then
|
2008-04-24 08:29:47 +00:00
|
|
|
this function is called. Otherwise, the current major mode menu is used."
|
2008-01-31 10:32:52 +00:00
|
|
|
(interactive "@e \nP")
|
|
|
|
(if (and (= (event-click-count event) 1)
|
2008-04-24 08:29:47 +00:00
|
|
|
(or (not mark-active)
|
2008-01-31 10:32:52 +00:00
|
|
|
(sit-for (/ double-click-time 1000.0))))
|
|
|
|
(progn
|
2008-12-16 16:24:04 +00:00
|
|
|
(select-window (posn-window (event-start event)))
|
2008-01-31 10:33:13 +00:00
|
|
|
(when (not (org-mouse-mark-active))
|
|
|
|
(goto-char (posn-point (event-start event)))
|
|
|
|
(when (not (eolp)) (save-excursion (run-hooks 'post-command-hook)))
|
2015-04-22 07:51:52 +00:00
|
|
|
(sit-for 0))
|
2008-01-31 10:32:52 +00:00
|
|
|
(if (functionp org-mouse-context-menu-function)
|
2008-01-31 10:33:13 +00:00
|
|
|
(funcall org-mouse-context-menu-function event)
|
2009-01-18 07:12:12 +00:00
|
|
|
(if (fboundp 'mouse-menu-major-mode-map)
|
|
|
|
(popup-menu (mouse-menu-major-mode-map) event prefix)
|
2016-06-23 13:20:32 +00:00
|
|
|
(with-no-warnings ; don't warn about fallback, obsolete since 23.1
|
Export: Better detection of images that can be inlined.
Two new variables, `org-export-html-inline-image-extensions' and
`org-export-latex-inline-image-extensions' now define the file
extensions that will be considered for inlining images. The default
for HTML is png, jpg, jpeg, and gif files. The default for LaTeX is
png, jpg, jpeg, and pdf, assuming processing with `pdflatex'.
For LaTeX export, this can lead to conflicts for links that point
to non-image PDF files. To avoid that such a link will be inlined by
accident, always give a description text for such a link, one that is
not equal to the path.
2009-01-18 08:11:24 +00:00
|
|
|
(mouse-major-mode-menu event prefix)))))
|
2008-01-31 10:32:52 +00:00
|
|
|
(setq this-command 'mouse-save-then-kill)
|
|
|
|
(mouse-save-then-kill event)))
|
|
|
|
|
|
|
|
(defun org-mouse-line-position ()
|
2010-07-16 21:23:01 +00:00
|
|
|
"Return `:beginning' or `:middle' or `:end', depending on the point position.
|
2008-01-31 10:36:18 +00:00
|
|
|
|
|
|
|
If the point is at the end of the line, return `:end'.
|
|
|
|
If the point is separated from the beginning of the line only by white
|
|
|
|
space and *'s (`org-mouse-bolp'), return `:beginning'. Otherwise,
|
|
|
|
return `:middle'."
|
2008-01-31 10:32:52 +00:00
|
|
|
(cond
|
|
|
|
((eolp) :end)
|
2008-01-31 10:36:18 +00:00
|
|
|
((org-mouse-bolp) :beginning)
|
2008-01-31 10:32:52 +00:00
|
|
|
(t :middle)))
|
|
|
|
|
|
|
|
(defun org-mouse-empty-line ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Return non-nil iff the line contains only white space."
|
2008-01-31 10:32:52 +00:00
|
|
|
(save-excursion (beginning-of-line) (looking-at "[ \t]*$")))
|
|
|
|
|
|
|
|
(defun org-mouse-next-heading ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Go to the next heading.
|
|
|
|
If there is none, ensure that the point is at the beginning of an empty line."
|
2008-01-31 10:32:52 +00:00
|
|
|
(unless (outline-next-heading)
|
|
|
|
(beginning-of-line)
|
|
|
|
(unless (org-mouse-empty-line)
|
|
|
|
(end-of-line)
|
|
|
|
(newline))))
|
|
|
|
|
|
|
|
(defun org-mouse-insert-heading ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Insert a new heading, as `org-insert-heading'.
|
|
|
|
|
|
|
|
If the point is at the :beginning (`org-mouse-line-position') of the line,
|
|
|
|
insert the new heading before the current line. Otherwise, insert it
|
|
|
|
after the current heading."
|
2008-01-31 10:32:52 +00:00
|
|
|
(interactive)
|
2016-07-25 13:44:49 +00:00
|
|
|
(cl-case (org-mouse-line-position)
|
2008-01-31 10:36:18 +00:00
|
|
|
(:beginning (beginning-of-line)
|
2012-08-11 17:10:44 +00:00
|
|
|
(org-insert-heading))
|
2008-01-31 10:32:52 +00:00
|
|
|
(t (org-mouse-next-heading)
|
|
|
|
(org-insert-heading))))
|
|
|
|
|
2008-04-24 08:29:47 +00:00
|
|
|
(defun org-mouse-timestamp-today (&optional shift units)
|
|
|
|
"Change the timestamp into SHIFT UNITS in the future.
|
2008-01-31 10:36:18 +00:00
|
|
|
|
|
|
|
For the acceptable UNITS, see `org-timestamp-change'."
|
2008-01-31 10:32:52 +00:00
|
|
|
(interactive)
|
2012-08-10 12:57:19 +00:00
|
|
|
(org-time-stamp nil)
|
|
|
|
(when shift (org-timestamp-change shift units)))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defun org-mouse-keyword-menu (keywords function &optional selected itemformat)
|
2008-01-31 10:36:18 +00:00
|
|
|
"A helper function.
|
|
|
|
|
|
|
|
Returns a menu fragment consisting of KEYWORDS. When a keyword
|
|
|
|
is selected by the user, FUNCTION is called with the selected
|
|
|
|
keyword as the only argument.
|
|
|
|
|
|
|
|
If SELECTED is nil, then all items are normal menu items. If
|
|
|
|
SELECTED is a function, then each item is a checkbox, which is
|
|
|
|
enabled for a given keyword iff (funcall SELECTED keyword) return
|
|
|
|
non-nil. If SELECTED is neither nil nor a function, then the
|
|
|
|
items are radio buttons. A radio button is enabled for the
|
2008-04-24 08:29:47 +00:00
|
|
|
keyword `equal' to SELECTED.
|
2008-01-31 10:36:18 +00:00
|
|
|
|
|
|
|
ITEMFORMAT governs formatting of the elements of KEYWORDS. If it
|
|
|
|
is a function, it is invoked with the keyword as the only
|
|
|
|
argument. If it is a string, it is interpreted as the format
|
|
|
|
string to (format ITEMFORMAT keyword). If it is neither a string
|
2010-07-16 21:23:01 +00:00
|
|
|
nor a function, elements of KEYWORDS are used directly."
|
2008-04-24 08:29:47 +00:00
|
|
|
(mapcar
|
|
|
|
`(lambda (keyword)
|
2012-08-11 17:10:44 +00:00
|
|
|
(vector (cond
|
|
|
|
((functionp ,itemformat) (funcall ,itemformat keyword))
|
|
|
|
((stringp ,itemformat) (format ,itemformat keyword))
|
|
|
|
(t keyword))
|
|
|
|
(list 'funcall ,function keyword)
|
|
|
|
:style (cond
|
|
|
|
((null ,selected) t)
|
|
|
|
((functionp ,selected) 'toggle)
|
|
|
|
(t 'radio))
|
|
|
|
:selected (if (functionp ,selected)
|
|
|
|
(and (funcall ,selected keyword) t)
|
|
|
|
(equal ,selected keyword))))
|
|
|
|
keywords))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-remove-match-and-spaces ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Remove the match, make just one space around the point."
|
2008-01-31 10:32:52 +00:00
|
|
|
(interactive)
|
|
|
|
(replace-match "")
|
2008-01-31 10:33:13 +00:00
|
|
|
(just-one-space))
|
|
|
|
|
2012-03-30 19:48:15 +00:00
|
|
|
(defvar org-mouse-rest)
|
2016-06-21 21:12:23 +00:00
|
|
|
(defun org-mouse-replace-match-and-surround
|
|
|
|
(_newtext &optional _fixedcase _literal _string subexp)
|
2008-01-31 10:36:18 +00:00
|
|
|
"The same as `replace-match', but surrounds the replacement with spaces."
|
2016-06-21 21:12:23 +00:00
|
|
|
(apply #'replace-match org-mouse-rest)
|
2008-01-31 10:33:13 +00:00
|
|
|
(save-excursion
|
2008-04-24 08:29:47 +00:00
|
|
|
(goto-char (match-beginning (or subexp 0)))
|
2008-01-31 10:33:13 +00:00
|
|
|
(just-one-space)
|
2008-04-24 08:29:47 +00:00
|
|
|
(goto-char (match-end (or subexp 0)))
|
2008-01-31 10:33:13 +00:00
|
|
|
(just-one-space)))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:33:46 +00:00
|
|
|
(defun org-mouse-keyword-replace-menu (keywords &optional group itemformat
|
|
|
|
nosurround)
|
2008-01-31 10:36:18 +00:00
|
|
|
"A helper function.
|
|
|
|
|
|
|
|
Returns a menu fragment consisting of KEYWORDS. When a keyword
|
|
|
|
is selected, group GROUP of the current match is replaced by the
|
|
|
|
keyword. The method ensures that both ends of the replacement
|
|
|
|
are separated from the rest of the text in the buffer by
|
2008-12-16 16:25:37 +00:00
|
|
|
individual spaces (unless NOSURROUND is non-nil).
|
2008-01-31 10:36:18 +00:00
|
|
|
|
|
|
|
The final entry of the menu is always \"None\", which removes the
|
|
|
|
match.
|
|
|
|
|
|
|
|
ITEMFORMAT governs formatting of the elements of KEYWORDS. If it
|
|
|
|
is a function, it is invoked with the keyword as the only
|
|
|
|
argument. If it is a string, it is interpreted as the format
|
|
|
|
string to (format ITEMFORMAT keyword). If it is neither a string
|
2010-07-16 21:23:01 +00:00
|
|
|
nor a function, elements of KEYWORDS are used directly."
|
2008-01-31 10:32:52 +00:00
|
|
|
(setq group (or group 0))
|
2008-04-24 08:29:47 +00:00
|
|
|
(let ((replace (org-mouse-match-closure
|
2008-01-31 10:33:46 +00:00
|
|
|
(if nosurround 'replace-match
|
|
|
|
'org-mouse-replace-match-and-surround))))
|
2008-01-31 10:33:13 +00:00
|
|
|
(append
|
2008-04-24 08:29:47 +00:00
|
|
|
(org-mouse-keyword-menu
|
2008-01-31 10:33:13 +00:00
|
|
|
keywords
|
|
|
|
`(lambda (keyword) (funcall ,replace keyword t t nil ,group))
|
|
|
|
(match-string group)
|
|
|
|
itemformat)
|
2008-04-24 08:29:47 +00:00
|
|
|
`(["None" org-mouse-remove-match-and-spaces
|
2008-01-31 10:33:13 +00:00
|
|
|
:style radio
|
|
|
|
:selected ,(not (member (match-string group) keywords))]))))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-show-headlines ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Change the visibility of the current org buffer to only show headlines."
|
2008-04-24 08:29:47 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((this-command 'org-cycle)
|
2008-01-31 10:32:52 +00:00
|
|
|
(last-command 'org-cycle)
|
|
|
|
(org-cycle-global-status nil))
|
|
|
|
(org-cycle '(4))
|
|
|
|
(org-cycle '(4))))
|
|
|
|
|
|
|
|
(defun org-mouse-show-overview ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Change visibility of current org buffer to first-level headlines only."
|
2008-04-24 08:29:47 +00:00
|
|
|
(interactive)
|
2008-01-31 10:32:52 +00:00
|
|
|
(let ((org-cycle-global-status nil))
|
|
|
|
(org-cycle '(4))))
|
|
|
|
|
|
|
|
(defun org-mouse-set-priority (priority)
|
2008-01-31 10:36:18 +00:00
|
|
|
"Set the priority of the current headline to PRIORITY."
|
2012-08-10 12:57:19 +00:00
|
|
|
(org-priority priority))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]"
|
2008-01-31 10:36:18 +00:00
|
|
|
"Regular expression matching the priority indicator.
|
|
|
|
Differs from `org-priority-regexp' in that it doesn't contain the
|
2015-09-21 04:23:36 +00:00
|
|
|
leading `.*?'.")
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defun org-mouse-get-priority (&optional default)
|
2008-01-31 10:36:18 +00:00
|
|
|
"Return the priority of the current headline.
|
|
|
|
DEFAULT is returned if no priority is given in the headline."
|
2008-04-24 08:29:47 +00:00
|
|
|
(save-excursion
|
2008-01-31 10:32:52 +00:00
|
|
|
(if (org-mouse-re-search-line org-mouse-priority-regexp)
|
|
|
|
(match-string 1)
|
2020-01-30 13:56:38 +00:00
|
|
|
(when default (char-to-string org-priority-default)))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defun org-mouse-delete-timestamp ()
|
2008-01-31 10:36:18 +00:00
|
|
|
"Deletes the current timestamp as well as the preceding keyword.
|
2008-01-31 10:32:52 +00:00
|
|
|
SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
2017-05-14 08:38:26 +00:00
|
|
|
(when (or (org-at-date-range-p) (org-at-timestamp-p 'lax))
|
|
|
|
(replace-match "") ;delete the timestamp
|
2008-01-31 10:32:52 +00:00
|
|
|
(skip-chars-backward " :A-Z")
|
|
|
|
(when (looking-at " *[A-Z][A-Z]+:")
|
|
|
|
(replace-match ""))))
|
|
|
|
|
2008-04-24 08:29:47 +00:00
|
|
|
(defun org-mouse-looking-at (regexp skipchars &optional movechars)
|
2008-01-31 10:32:52 +00:00
|
|
|
(save-excursion
|
|
|
|
(let ((point (point)))
|
|
|
|
(if (looking-at regexp) t
|
|
|
|
(skip-chars-backward skipchars)
|
|
|
|
(forward-char (or movechars 0))
|
|
|
|
(when (looking-at regexp)
|
|
|
|
(> (match-end 0) point))))))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-priority-list ()
|
2020-01-30 13:56:38 +00:00
|
|
|
(cl-loop for priority from ?A to org-priority-lowest
|
2016-07-25 13:44:49 +00:00
|
|
|
collect (char-to-string priority)))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2009-03-21 18:39:17 +00:00
|
|
|
(defun org-mouse-todo-menu (state)
|
|
|
|
"Create the menu with TODO keywords."
|
|
|
|
(append
|
|
|
|
(let ((kwds org-todo-keywords-1))
|
|
|
|
(org-mouse-keyword-menu
|
|
|
|
kwds
|
|
|
|
`(lambda (kwd) (org-todo kwd))
|
|
|
|
(lambda (kwd) (equal state kwd))))))
|
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-tag-menu () ;todo
|
2010-07-16 21:23:01 +00:00
|
|
|
"Create the tags menu."
|
2008-01-31 10:32:52 +00:00
|
|
|
(append
|
2018-04-18 15:28:52 +00:00
|
|
|
(let ((tags (org-get-tags nil t)))
|
2008-04-24 08:29:47 +00:00
|
|
|
(org-mouse-keyword-menu
|
2008-01-31 10:32:52 +00:00
|
|
|
(sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
|
2008-04-24 08:29:47 +00:00
|
|
|
`(lambda (tag)
|
|
|
|
(org-mouse-set-tags
|
|
|
|
(sort (if (member tag (quote ,tags))
|
2008-01-31 10:32:52 +00:00
|
|
|
(delete tag (quote ,tags))
|
|
|
|
(cons tag (quote ,tags)))
|
|
|
|
'string-lessp)))
|
|
|
|
`(lambda (tag) (member tag (quote ,tags)))
|
|
|
|
))
|
|
|
|
'("--"
|
2018-04-20 08:45:19 +00:00
|
|
|
["Align Tags Here" (org-align-tags) t]
|
|
|
|
["Align Tags in Buffer" (org-align-tags t) t]
|
|
|
|
["Set Tags ..." (org-set-tags-command) t])))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-set-tags (tags)
|
2018-04-20 08:45:19 +00:00
|
|
|
(org-set-tags tags))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-insert-checkbox ()
|
|
|
|
(interactive)
|
|
|
|
(and (org-at-item-p)
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
(unless (org-at-item-checkbox-p)
|
|
|
|
(delete-horizontal-space)
|
|
|
|
(insert " [ ] "))))
|
|
|
|
|
|
|
|
(defun org-mouse-agenda-type (type)
|
2016-07-25 13:44:49 +00:00
|
|
|
(pcase type
|
|
|
|
(`tags "Tags: ")
|
|
|
|
(`todo "TODO: ")
|
|
|
|
(`tags-tree "Tags tree: ")
|
|
|
|
(`todo-tree "TODO tree: ")
|
|
|
|
(`occur-tree "Occur tree: ")
|
|
|
|
(_ "Agenda command ???")))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2008-01-31 10:33:13 +00:00
|
|
|
(defun org-mouse-list-options-menu (alloptions &optional function)
|
2008-04-24 08:29:47 +00:00
|
|
|
(let ((options (save-match-data
|
2008-01-31 10:33:13 +00:00
|
|
|
(split-string (match-string-no-properties 1)))))
|
|
|
|
(print options)
|
2016-07-25 13:44:49 +00:00
|
|
|
(cl-loop for name in alloptions
|
|
|
|
collect
|
|
|
|
(vector name
|
|
|
|
`(progn
|
|
|
|
(replace-match
|
|
|
|
(mapconcat 'identity
|
|
|
|
(sort (if (member ',name ',options)
|
|
|
|
(delete ',name ',options)
|
|
|
|
(cons ',name ',options))
|
|
|
|
'string-lessp)
|
|
|
|
" ")
|
|
|
|
nil nil nil 1)
|
|
|
|
(when (functionp ',function) (funcall ',function)))
|
|
|
|
:style 'toggle
|
|
|
|
:selected (and (member name options) t)))))
|
2008-01-31 10:33:13 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-clip-text (text maxlength)
|
|
|
|
(if (> (length text) maxlength)
|
|
|
|
(concat (substring text 0 (- maxlength 3)) "...")
|
|
|
|
text))
|
|
|
|
|
|
|
|
(defun org-mouse-popup-global-menu ()
|
2008-04-24 08:29:47 +00:00
|
|
|
(popup-menu
|
2008-01-31 10:32:52 +00:00
|
|
|
`("Main Menu"
|
|
|
|
["Show Overview" org-mouse-show-overview t]
|
|
|
|
["Show Headlines" org-mouse-show-headlines t]
|
2017-12-06 15:03:23 +00:00
|
|
|
["Show All" org-show-all t]
|
2008-01-31 10:32:52 +00:00
|
|
|
["Remove Highlights" org-remove-occur-highlights
|
|
|
|
:visible org-occur-highlights]
|
|
|
|
"--"
|
2008-04-24 08:29:47 +00:00
|
|
|
["Check Deadlines"
|
2008-01-31 10:32:52 +00:00
|
|
|
(if (functionp 'org-check-deadlines-and-todos)
|
|
|
|
(org-check-deadlines-and-todos org-deadline-warning-days)
|
2020-02-18 21:57:37 +00:00
|
|
|
(org-check-deadlines org-deadline-warning-days))
|
|
|
|
t]
|
2008-01-31 10:32:52 +00:00
|
|
|
["Check TODOs" org-show-todo-tree t]
|
2008-04-24 08:29:47 +00:00
|
|
|
("Check Tags"
|
|
|
|
,@(org-mouse-keyword-menu
|
2008-01-31 10:32:52 +00:00
|
|
|
(sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
|
2021-03-30 14:19:06 +00:00
|
|
|
(lambda (tag) (org-tags-sparse-tree nil tag)))
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
|
|
|
["Custom Tag ..." org-tags-sparse-tree t])
|
|
|
|
["Check Phrase ..." org-occur]
|
|
|
|
"--"
|
|
|
|
["Display Agenda" org-agenda-list t]
|
|
|
|
["Display TODO List" org-todo-list t]
|
2008-04-24 08:29:47 +00:00
|
|
|
("Display Tags"
|
|
|
|
,@(org-mouse-keyword-menu
|
2008-01-31 10:32:52 +00:00
|
|
|
(sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
|
2021-03-30 14:19:06 +00:00
|
|
|
(lambda (tag) (org-tags-view nil tag)))
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
|
|
|
["Custom Tag ..." org-tags-view t])
|
|
|
|
["Display Calendar" org-goto-calendar t]
|
|
|
|
"--"
|
2008-04-24 08:29:47 +00:00
|
|
|
,@(org-mouse-keyword-menu
|
2008-01-31 10:32:52 +00:00
|
|
|
(mapcar 'car org-agenda-custom-commands)
|
2021-03-30 14:19:06 +00:00
|
|
|
(lambda (key)
|
|
|
|
(eval `(org-agenda nil (string-to-char ,key))))
|
2008-04-24 08:29:47 +00:00
|
|
|
nil
|
2021-03-30 14:19:06 +00:00
|
|
|
(lambda (key)
|
|
|
|
(let ((entry (assoc key org-agenda-custom-commands)))
|
|
|
|
(org-mouse-clip-text
|
|
|
|
(cond
|
|
|
|
((stringp (nth 1 entry)) (nth 1 entry))
|
|
|
|
((stringp (nth 2 entry))
|
|
|
|
(concat (org-mouse-agenda-type (nth 1 entry))
|
|
|
|
(nth 2 entry)))
|
|
|
|
(t "Agenda Command `%s'"))
|
|
|
|
30))))
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
2008-04-24 08:29:47 +00:00
|
|
|
["Delete Blank Lines" delete-blank-lines
|
2008-01-31 10:32:52 +00:00
|
|
|
:visible (org-mouse-empty-line)]
|
|
|
|
["Insert Checkbox" org-mouse-insert-checkbox
|
|
|
|
:visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
|
2008-04-24 08:29:47 +00:00
|
|
|
["Insert Checkboxes"
|
2008-01-31 10:32:52 +00:00
|
|
|
(org-mouse-for-each-item 'org-mouse-insert-checkbox)
|
|
|
|
:visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))]
|
|
|
|
["Plain List to Outline" org-mouse-transform-to-outline
|
|
|
|
:visible (org-at-item-p)])))
|
|
|
|
|
|
|
|
(defun org-mouse-get-context (contextlist context)
|
2008-01-31 10:33:46 +00:00
|
|
|
(let ((contextdata (assq context contextlist)))
|
2008-01-31 10:32:52 +00:00
|
|
|
(when contextdata
|
2008-04-24 08:29:47 +00:00
|
|
|
(save-excursion
|
2016-07-25 14:34:48 +00:00
|
|
|
(goto-char (nth 1 contextdata))
|
|
|
|
(re-search-forward ".*" (nth 2 contextdata))))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2010-09-12 11:15:48 +00:00
|
|
|
(defun org-mouse-for-each-item (funct)
|
2016-06-21 21:12:23 +00:00
|
|
|
;; Functions called by `org-apply-on-list' need an argument.
|
|
|
|
(let ((wrap-fun (lambda (_) (funcall funct))))
|
2011-01-10 17:55:39 +00:00
|
|
|
(when (ignore-errors (goto-char (org-in-item-p)))
|
|
|
|
(save-excursion (org-apply-on-list wrap-fun nil)))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defun org-mouse-bolp ()
|
2015-09-21 04:23:36 +00:00
|
|
|
"Return true if there only spaces, tabs, and `*' before point.
|
2010-07-16 21:23:01 +00:00
|
|
|
This means, between the beginning of line and the point."
|
2008-01-31 10:32:52 +00:00
|
|
|
(save-excursion
|
|
|
|
(skip-chars-backward " \t*") (bolp)))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:33:13 +00:00
|
|
|
(defun org-mouse-insert-item (text)
|
2016-07-25 13:44:49 +00:00
|
|
|
(cl-case (org-mouse-line-position)
|
|
|
|
(:beginning ; insert before
|
2008-04-24 08:29:47 +00:00
|
|
|
(beginning-of-line)
|
2008-01-31 10:33:13 +00:00
|
|
|
(looking-at "[ \t]*")
|
|
|
|
(open-line 1)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
(indent-to-column (- (match-end 0) (match-beginning 0)))
|
2008-01-31 10:33:13 +00:00
|
|
|
(insert "+ "))
|
2016-07-25 13:44:49 +00:00
|
|
|
(:middle ; insert after
|
2008-04-24 08:29:47 +00:00
|
|
|
(end-of-line)
|
|
|
|
(newline t)
|
2008-01-31 10:33:13 +00:00
|
|
|
(indent-relative)
|
|
|
|
(insert "+ "))
|
|
|
|
(:end ; insert text here
|
2008-04-24 08:29:47 +00:00
|
|
|
(skip-chars-backward " \t")
|
2008-01-31 10:33:13 +00:00
|
|
|
(kill-region (point) (point-at-eol))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
(unless (looking-back org-mouse-punctuation (line-beginning-position))
|
2008-01-31 10:33:13 +00:00
|
|
|
(insert (concat org-mouse-punctuation " ")))))
|
|
|
|
(insert text)
|
|
|
|
(beginning-of-line))
|
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
|
Use (derived-mode-p 'org-mode) instead of (eq major-mode 'org-mode).
* org.el (org-show-hierarchy-above, org-cycle)
(org-global-cycle, org-files-list, org-store-link)
(org-link-search, org-open-file, org-display-outline-path)
(org-refile-get-location, org-update-all-dblocks)
(org-change-tag-in-region, org-entry-properties)
(org-save-all-org-buffers, org-revert-all-org-buffers)
(org-buffer-list, org-cdlatex-mode)
(org-install-agenda-files-menu, org-end-of-subtree)
(org-speedbar-set-agenda-restriction): Use (derived-mode-p
'org-mode) instead of (eq major-mode 'org-mode).
* org-timer.el (org-timer-set-timer): Ditto.
* org-table.el (orgtbl-mode, org-table-align, orgtbl-mode): Ditto.
* org-src.el (org-edit-src-exit, org-edit-src-code)
(org-edit-fixed-width-region, org-edit-src-exit): Ditto.
* org-remember.el (org-remember-handler): Ditto.
* org-mouse.el (dnd-open-file, org-mouse-insert-item): Ditto.
* org-macs.el (org-get-limited-outline-regexp): Ditto.
* org-lparse.el (org-replace-region-by): Ditto.
* org-latex.el (org-latex-to-pdf-process)
(org-replace-region-by-latex): Ditto.
* org-indent.el (org-indent-indent-buffer): Ditto.
* org-id.el (org-id-store-link, org-id-update-id-locations)
(org-id-store-link): Ditto.
* org-html.el (org-export-html-preprocess)
(org-replace-region-by-html): Ditto.
* org-footnote.el (org-footnote-normalize)
(org-footnote-goto-definition)
(org-footnote-create-definition, org-footnote-normalize): Ditto.
* org-docbook.el (org-replace-region-by-docbook): Ditto.
* org-ctags.el (find-tag): Ditto.
* org-colview.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-colview-xemacs.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-capture.el (org-capture-insert-template-here)
(org-capture, org-capture-finalize)
(org-capture-set-target-location)
(org-capture-insert-template-here): Ditto.
* org-ascii.el (org-replace-region-by-ascii): Ditto.
* org-archive.el (org-archive-subtree): Ditto.
* org-agenda.el (org-agenda)
(org-agenda-get-restriction-and-command)
(org-agenda-get-some-entry-text, org-search-view)
(org-tags-view, org-agenda-get-day-entries)
(org-agenda-format-item, org-agenda-goto, org-agenda-kill)
(org-agenda-archive-with, org-agenda-switch-to): Ditto.
2012-04-20 18:03:45 +00:00
|
|
|
(if (derived-mode-p 'org-mode)
|
2008-01-31 10:33:13 +00:00
|
|
|
(org-mouse-insert-item text)
|
2008-01-31 10:32:52 +00:00
|
|
|
ad-do-it))
|
|
|
|
|
2008-01-31 10:33:13 +00:00
|
|
|
(defadvice dnd-open-file (around org-mouse-dnd-open-file activate)
|
Use (derived-mode-p 'org-mode) instead of (eq major-mode 'org-mode).
* org.el (org-show-hierarchy-above, org-cycle)
(org-global-cycle, org-files-list, org-store-link)
(org-link-search, org-open-file, org-display-outline-path)
(org-refile-get-location, org-update-all-dblocks)
(org-change-tag-in-region, org-entry-properties)
(org-save-all-org-buffers, org-revert-all-org-buffers)
(org-buffer-list, org-cdlatex-mode)
(org-install-agenda-files-menu, org-end-of-subtree)
(org-speedbar-set-agenda-restriction): Use (derived-mode-p
'org-mode) instead of (eq major-mode 'org-mode).
* org-timer.el (org-timer-set-timer): Ditto.
* org-table.el (orgtbl-mode, org-table-align, orgtbl-mode): Ditto.
* org-src.el (org-edit-src-exit, org-edit-src-code)
(org-edit-fixed-width-region, org-edit-src-exit): Ditto.
* org-remember.el (org-remember-handler): Ditto.
* org-mouse.el (dnd-open-file, org-mouse-insert-item): Ditto.
* org-macs.el (org-get-limited-outline-regexp): Ditto.
* org-lparse.el (org-replace-region-by): Ditto.
* org-latex.el (org-latex-to-pdf-process)
(org-replace-region-by-latex): Ditto.
* org-indent.el (org-indent-indent-buffer): Ditto.
* org-id.el (org-id-store-link, org-id-update-id-locations)
(org-id-store-link): Ditto.
* org-html.el (org-export-html-preprocess)
(org-replace-region-by-html): Ditto.
* org-footnote.el (org-footnote-normalize)
(org-footnote-goto-definition)
(org-footnote-create-definition, org-footnote-normalize): Ditto.
* org-docbook.el (org-replace-region-by-docbook): Ditto.
* org-ctags.el (find-tag): Ditto.
* org-colview.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-colview-xemacs.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-capture.el (org-capture-insert-template-here)
(org-capture, org-capture-finalize)
(org-capture-set-target-location)
(org-capture-insert-template-here): Ditto.
* org-ascii.el (org-replace-region-by-ascii): Ditto.
* org-archive.el (org-archive-subtree): Ditto.
* org-agenda.el (org-agenda)
(org-agenda-get-restriction-and-command)
(org-agenda-get-some-entry-text, org-search-view)
(org-tags-view, org-agenda-get-day-entries)
(org-agenda-format-item, org-agenda-goto, org-agenda-kill)
(org-agenda-archive-with, org-agenda-switch-to): Ditto.
2012-04-20 18:03:45 +00:00
|
|
|
(if (derived-mode-p 'org-mode)
|
2008-01-31 10:33:13 +00:00
|
|
|
(org-mouse-insert-item uri)
|
|
|
|
ad-do-it))
|
|
|
|
|
|
|
|
(defun org-mouse-match-closure (function)
|
|
|
|
(let ((match (match-data t)))
|
2008-04-24 08:29:47 +00:00
|
|
|
`(lambda (&rest rest)
|
2012-08-11 17:10:44 +00:00
|
|
|
(save-match-data
|
|
|
|
(set-match-data ',match)
|
|
|
|
(apply ',function rest)))))
|
2008-01-31 10:33:13 +00:00
|
|
|
|
|
|
|
(defun org-mouse-yank-link (click)
|
|
|
|
(interactive "e")
|
|
|
|
;; Give temporary modes such as isearch a chance to turn off.
|
|
|
|
(run-hooks 'mouse-leave-buffer-hook)
|
|
|
|
(mouse-set-point click)
|
|
|
|
(setq mouse-selection-click-count 0)
|
|
|
|
(delete-horizontal-space)
|
|
|
|
(insert-for-yank (concat " [[" (current-kill 0) "]] ")))
|
|
|
|
|
|
|
|
(defun org-mouse-context-menu (&optional event)
|
2012-08-10 12:57:19 +00:00
|
|
|
(let* ((stamp-prefixes (list org-deadline-string org-scheduled-string))
|
|
|
|
(contextlist (org-context))
|
|
|
|
(get-context (lambda (context) (org-mouse-get-context contextlist context))))
|
|
|
|
(cond
|
|
|
|
((org-mouse-mark-active)
|
|
|
|
(let ((region-string (buffer-substring (region-beginning) (region-end))))
|
|
|
|
(popup-menu
|
|
|
|
`(nil
|
|
|
|
["Sparse Tree" (org-occur ',region-string)]
|
|
|
|
["Find in Buffer" (occur ',region-string)]
|
|
|
|
["Grep in Current Dir"
|
|
|
|
(grep (format "grep -rnH -e '%s' *" ',region-string))]
|
|
|
|
["Grep in Parent Dir"
|
|
|
|
(grep (format "grep -rnH -e '%s' ../*" ',region-string))]
|
|
|
|
"--"
|
|
|
|
["Convert to Link"
|
|
|
|
(progn (save-excursion (goto-char (region-beginning)) (insert "[["))
|
|
|
|
(save-excursion (goto-char (region-end)) (insert "]]")))]
|
|
|
|
["Insert Link Here" (org-mouse-yank-link ',event)]))))
|
2014-03-13 10:28:07 +00:00
|
|
|
((save-excursion (beginning-of-line) (looking-at "[ \t]*#\\+STARTUP: \\(.*\\)"))
|
2008-01-31 10:33:13 +00:00
|
|
|
(popup-menu
|
|
|
|
`(nil
|
2012-08-10 12:57:19 +00:00
|
|
|
,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
|
|
|
|
'org-mode-restart))))
|
|
|
|
((or (eolp)
|
2019-03-05 02:00:00 +00:00
|
|
|
(and (looking-at "\\( \\|\t\\)\\(\\+:[0-9a-zA-Z_:]+\\)?\\( \\|\t\\)+$")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
(looking-back " \\|\t" (- (point) 2)
|
2016-07-25 13:44:49 +00:00
|
|
|
(line-beginning-position))))
|
2012-08-10 12:57:19 +00:00
|
|
|
(org-mouse-popup-global-menu))
|
|
|
|
((funcall get-context :checkbox)
|
|
|
|
(popup-menu
|
|
|
|
'(nil
|
|
|
|
["Toggle" org-toggle-checkbox t]
|
|
|
|
["Remove" org-mouse-remove-match-and-spaces t]
|
|
|
|
""
|
|
|
|
["All Clear" (org-mouse-for-each-item
|
|
|
|
(lambda ()
|
|
|
|
(when (save-excursion (org-at-item-checkbox-p))
|
2013-05-24 17:10:38 +00:00
|
|
|
(replace-match "[ ] "))))]
|
2012-08-10 12:57:19 +00:00
|
|
|
["All Set" (org-mouse-for-each-item
|
2008-01-31 10:32:52 +00:00
|
|
|
(lambda ()
|
|
|
|
(when (save-excursion (org-at-item-checkbox-p))
|
2013-05-24 17:10:38 +00:00
|
|
|
(replace-match "[X] "))))]
|
2012-08-10 12:57:19 +00:00
|
|
|
["All Toggle" (org-mouse-for-each-item 'org-toggle-checkbox) t]
|
|
|
|
["All Remove" (org-mouse-for-each-item
|
|
|
|
(lambda ()
|
|
|
|
(when (save-excursion (org-at-item-checkbox-p))
|
|
|
|
(org-mouse-remove-match-and-spaces))))]
|
|
|
|
)))
|
|
|
|
((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_")
|
|
|
|
(member (match-string 0) org-todo-keywords-1))
|
|
|
|
(popup-menu
|
|
|
|
`(nil
|
|
|
|
,@(org-mouse-todo-menu (match-string 0))
|
2008-01-31 10:33:46 +00:00
|
|
|
"--"
|
2012-08-10 12:57:19 +00:00
|
|
|
["Check TODOs" org-show-todo-tree t]
|
|
|
|
["List all TODO keywords" org-todo-list t]
|
|
|
|
[,(format "List only %s" (match-string 0))
|
|
|
|
(org-todo-list (match-string 0)) t]
|
|
|
|
)))
|
|
|
|
((and (org-mouse-looking-at "\\b[A-Z]+:" "A-Z")
|
|
|
|
(member (match-string 0) stamp-prefixes))
|
|
|
|
(popup-menu
|
|
|
|
`(nil
|
|
|
|
,@(org-mouse-keyword-replace-menu stamp-prefixes)
|
2008-01-31 10:33:46 +00:00
|
|
|
"--"
|
2012-08-10 12:57:19 +00:00
|
|
|
["Check Deadlines" org-check-deadlines t]
|
|
|
|
)))
|
|
|
|
((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority
|
|
|
|
(popup-menu `(nil ,@(org-mouse-keyword-replace-menu
|
|
|
|
(org-mouse-priority-list) 1 "Priority %s" t))))
|
|
|
|
((funcall get-context :link)
|
2008-01-31 10:32:52 +00:00
|
|
|
(popup-menu
|
2012-08-10 12:57:19 +00:00
|
|
|
'(nil
|
|
|
|
["Open" org-open-at-point t]
|
|
|
|
["Open in Emacs" (org-open-at-point t) t]
|
|
|
|
"--"
|
|
|
|
["Copy link" (org-kill-new (match-string 0))]
|
|
|
|
["Cut link"
|
|
|
|
(progn
|
|
|
|
(kill-region (match-beginning 0) (match-end 0))
|
|
|
|
(just-one-space))]
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
2012-08-10 12:57:19 +00:00
|
|
|
["Grep for TODOs"
|
|
|
|
(grep (format "grep -nH -i 'todo\\|fixme' %s*" (match-string 2)))]
|
|
|
|
; ["Paste file link" ((insert "file:") (yank))]
|
|
|
|
)))
|
|
|
|
((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags
|
|
|
|
(popup-menu
|
|
|
|
`(nil
|
2015-09-21 04:23:36 +00:00
|
|
|
[,(format-message "Display `%s'" (match-string 1))
|
2012-08-10 12:57:19 +00:00
|
|
|
(org-tags-view nil ,(match-string 1))]
|
2015-09-21 04:23:36 +00:00
|
|
|
[,(format-message "Sparse Tree `%s'" (match-string 1))
|
2012-08-10 12:57:19 +00:00
|
|
|
(org-tags-sparse-tree nil ,(match-string 1))]
|
|
|
|
"--"
|
|
|
|
,@(org-mouse-tag-menu))))
|
2017-05-14 08:38:26 +00:00
|
|
|
((org-at-timestamp-p 'lax)
|
2012-08-10 12:57:19 +00:00
|
|
|
(popup-menu
|
|
|
|
'(nil
|
|
|
|
["Show Day" org-open-at-point t]
|
|
|
|
["Change Timestamp" org-time-stamp t]
|
|
|
|
["Delete Timestamp" (org-mouse-delete-timestamp) t]
|
|
|
|
["Compute Time Range" org-evaluate-time-range (org-at-date-range-p)]
|
|
|
|
"--"
|
|
|
|
["Set for Today" org-mouse-timestamp-today]
|
|
|
|
["Set for Tomorrow" (org-mouse-timestamp-today 1 'day)]
|
|
|
|
["Set in 1 Week" (org-mouse-timestamp-today 7 'day)]
|
|
|
|
["Set in 2 Weeks" (org-mouse-timestamp-today 14 'day)]
|
|
|
|
["Set in a Month" (org-mouse-timestamp-today 1 'month)]
|
|
|
|
"--"
|
|
|
|
["+ 1 Day" (org-timestamp-change 1 'day)]
|
|
|
|
["+ 1 Week" (org-timestamp-change 7 'day)]
|
|
|
|
["+ 1 Month" (org-timestamp-change 1 'month)]
|
|
|
|
"--"
|
|
|
|
["- 1 Day" (org-timestamp-change -1 'day)]
|
|
|
|
["- 1 Week" (org-timestamp-change -7 'day)]
|
|
|
|
["- 1 Month" (org-timestamp-change -1 'month)])))
|
|
|
|
((funcall get-context :table-special)
|
|
|
|
(let ((mdata (match-data)))
|
2016-07-25 13:44:49 +00:00
|
|
|
(cl-incf (car mdata) 2)
|
2012-08-10 12:57:19 +00:00
|
|
|
(store-match-data mdata))
|
|
|
|
(message "match: %S" (match-string 0))
|
|
|
|
(popup-menu `(nil ,@(org-mouse-keyword-replace-menu
|
|
|
|
'(" " "!" "^" "_" "$" "#" "*" "'") 0
|
|
|
|
(lambda (mark)
|
2016-07-25 13:44:49 +00:00
|
|
|
(cl-case (string-to-char mark)
|
2012-08-10 12:57:19 +00:00
|
|
|
(? "( ) Nothing Special")
|
|
|
|
(?! "(!) Column Names")
|
|
|
|
(?^ "(^) Field Names Above")
|
|
|
|
(?_ "(^) Field Names Below")
|
|
|
|
(?$ "($) Formula Parameters")
|
|
|
|
(?# "(#) Recalculation: Auto")
|
|
|
|
(?* "(*) Recalculation: Manual")
|
2020-02-18 21:57:37 +00:00
|
|
|
(?' "(') Recalculation: None")))
|
|
|
|
t))))
|
2012-08-10 12:57:19 +00:00
|
|
|
((assq :table contextlist)
|
|
|
|
(popup-menu
|
|
|
|
'(nil
|
|
|
|
["Align Table" org-ctrl-c-ctrl-c]
|
|
|
|
["Blank Field" org-table-blank-field]
|
|
|
|
["Edit Field" org-table-edit-field]
|
|
|
|
"--"
|
|
|
|
("Column"
|
|
|
|
["Move Column Left" org-metaleft]
|
|
|
|
["Move Column Right" org-metaright]
|
|
|
|
["Delete Column" org-shiftmetaleft]
|
|
|
|
["Insert Column" org-shiftmetaright]
|
2008-01-31 10:33:46 +00:00
|
|
|
"--"
|
2012-08-10 12:57:19 +00:00
|
|
|
["Enable Narrowing" (setq org-table-limit-column-width (not org-table-limit-column-width)) :selected org-table-limit-column-width :style toggle])
|
|
|
|
("Row"
|
|
|
|
["Move Row Up" org-metaup]
|
|
|
|
["Move Row Down" org-metadown]
|
|
|
|
["Delete Row" org-shiftmetaup]
|
|
|
|
["Insert Row" org-shiftmetadown]
|
|
|
|
["Sort lines in region" org-table-sort-lines (org-at-table-p)]
|
|
|
|
"--"
|
|
|
|
["Insert Hline" org-table-insert-hline])
|
|
|
|
("Rectangle"
|
|
|
|
["Copy Rectangle" org-copy-special]
|
|
|
|
["Cut Rectangle" org-cut-special]
|
|
|
|
["Paste Rectangle" org-paste-special]
|
|
|
|
["Fill Rectangle" org-table-wrap-region])
|
|
|
|
"--"
|
|
|
|
["Set Column Formula" org-table-eval-formula]
|
|
|
|
["Set Field Formula" (org-table-eval-formula '(4))]
|
|
|
|
["Edit Formulas" org-table-edit-formulas]
|
|
|
|
"--"
|
|
|
|
["Recalculate Line" org-table-recalculate]
|
|
|
|
["Recalculate All" (org-table-recalculate '(4))]
|
|
|
|
["Iterate All" (org-table-recalculate '(16))]
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
2012-08-10 12:57:19 +00:00
|
|
|
["Toggle Recalculate Mark" org-table-rotate-recalc-marks]
|
|
|
|
["Sum Column/Rectangle" org-table-sum
|
|
|
|
:active (or (org-at-table-p) (org-region-active-p))]
|
|
|
|
["Field Info" org-table-field-info]
|
|
|
|
["Debug Formulas"
|
|
|
|
(setq org-table-formula-debug (not org-table-formula-debug))
|
|
|
|
:style toggle :selected org-table-formula-debug]
|
|
|
|
)))
|
|
|
|
((and (assq :headline contextlist) (not (eolp)))
|
|
|
|
(let ((priority (org-mouse-get-priority t)))
|
|
|
|
(popup-menu
|
|
|
|
`("Headline Menu"
|
|
|
|
("Tags and Priorities"
|
|
|
|
,@(org-mouse-keyword-menu
|
|
|
|
(org-mouse-priority-list)
|
2021-03-30 14:19:06 +00:00
|
|
|
(lambda (keyword)
|
|
|
|
(org-mouse-set-priority (string-to-char keyword)))
|
2012-08-10 12:57:19 +00:00
|
|
|
priority "Priority %s")
|
|
|
|
"--"
|
|
|
|
,@(org-mouse-tag-menu))
|
|
|
|
("TODO Status"
|
|
|
|
,@(org-mouse-todo-menu (org-get-todo-state)))
|
|
|
|
["Show Tags"
|
|
|
|
(with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
|
|
|
|
:visible (not org-mouse-direct)]
|
|
|
|
["Show Priority"
|
|
|
|
(with-current-buffer org-mouse-main-buffer (org-agenda-show-priority))
|
|
|
|
:visible (not org-mouse-direct)]
|
|
|
|
,@(if org-mouse-direct '("--") nil)
|
|
|
|
["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
|
|
|
|
["Set Deadline"
|
|
|
|
(progn (org-mouse-end-headline) (insert " ") (org-deadline))
|
|
|
|
:active (not (save-excursion
|
|
|
|
(org-mouse-re-search-line org-deadline-regexp)))]
|
|
|
|
["Schedule Task"
|
|
|
|
(progn (org-mouse-end-headline) (insert " ") (org-schedule))
|
|
|
|
:active (not (save-excursion
|
|
|
|
(org-mouse-re-search-line org-scheduled-regexp)))]
|
|
|
|
["Insert Timestamp"
|
|
|
|
(progn (org-mouse-end-headline) (insert " ") (org-time-stamp nil)) t]
|
|
|
|
; ["Timestamp (inactive)" org-time-stamp-inactive t]
|
|
|
|
"--"
|
|
|
|
["Archive Subtree" org-archive-subtree]
|
|
|
|
["Cut Subtree" org-cut-special]
|
|
|
|
["Copy Subtree" org-copy-special]
|
|
|
|
["Paste Subtree" org-paste-special :visible org-mouse-direct]
|
|
|
|
("Sort Children"
|
|
|
|
["Alphabetically" (org-sort-entries nil ?a)]
|
|
|
|
["Numerically" (org-sort-entries nil ?n)]
|
|
|
|
["By Time/Date" (org-sort-entries nil ?t)]
|
|
|
|
"--"
|
|
|
|
["Reverse Alphabetically" (org-sort-entries nil ?A)]
|
|
|
|
["Reverse Numerically" (org-sort-entries nil ?N)]
|
|
|
|
["Reverse By Time/Date" (org-sort-entries nil ?T)])
|
|
|
|
"--"
|
|
|
|
["Move Trees" org-mouse-move-tree :active nil]
|
|
|
|
))))
|
|
|
|
(t
|
|
|
|
(org-mouse-popup-global-menu)))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2008-01-31 10:33:13 +00:00
|
|
|
(defun org-mouse-mark-active ()
|
|
|
|
(and mark-active transient-mark-mode))
|
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-in-region-p (pos)
|
2008-04-24 08:29:47 +00:00
|
|
|
(and (org-mouse-mark-active)
|
|
|
|
(>= pos (region-beginning))
|
2008-01-31 10:33:13 +00:00
|
|
|
(< pos (region-end))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(defun org-mouse-down-mouse (event)
|
|
|
|
(interactive "e")
|
|
|
|
(setq this-command last-command)
|
2008-01-31 10:33:13 +00:00
|
|
|
(unless (and (= 1 (event-click-count event))
|
2008-01-31 10:32:52 +00:00
|
|
|
(org-mouse-in-region-p (posn-point (event-start event))))
|
|
|
|
(mouse-drag-region event)))
|
|
|
|
|
|
|
|
(add-hook 'org-mode-hook
|
2021-03-30 14:19:06 +00:00
|
|
|
(lambda ()
|
|
|
|
(setq org-mouse-context-menu-function 'org-mouse-context-menu)
|
|
|
|
|
|
|
|
(when (memq 'context-menu org-mouse-features)
|
|
|
|
(org-defkey org-mouse-map [mouse-3] nil)
|
|
|
|
(org-defkey org-mode-map [mouse-3] 'org-mouse-show-context-menu))
|
|
|
|
(org-defkey org-mode-map [down-mouse-1] 'org-mouse-down-mouse)
|
|
|
|
(when (memq 'context-menu org-mouse-features)
|
|
|
|
(org-defkey org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree)
|
|
|
|
(org-defkey org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start))
|
|
|
|
(when (memq 'yank-link org-mouse-features)
|
|
|
|
(org-defkey org-mode-map [S-mouse-2] 'org-mouse-yank-link)
|
|
|
|
(org-defkey org-mode-map [drag-mouse-3] 'org-mouse-yank-link))
|
|
|
|
(when (memq 'move-tree org-mouse-features)
|
|
|
|
(org-defkey org-mouse-map [drag-mouse-3] 'org-mouse-move-tree)
|
|
|
|
(org-defkey org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start))
|
|
|
|
|
|
|
|
(when (memq 'activate-stars org-mouse-features)
|
|
|
|
(font-lock-add-keywords
|
|
|
|
nil
|
|
|
|
`((,org-outline-regexp
|
|
|
|
0 `(face org-link mouse-face highlight keymap ,org-mouse-map)
|
|
|
|
'prepend))
|
|
|
|
t))
|
|
|
|
|
|
|
|
(when (memq 'activate-bullets org-mouse-features)
|
|
|
|
(font-lock-add-keywords
|
|
|
|
nil
|
|
|
|
`(("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +"
|
|
|
|
(1 `(face org-link keymap ,org-mouse-map mouse-face highlight)
|
|
|
|
'prepend)))
|
|
|
|
t))
|
|
|
|
|
|
|
|
(when (memq 'activate-checkboxes org-mouse-features)
|
|
|
|
(font-lock-add-keywords
|
|
|
|
nil
|
|
|
|
`(("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
|
2021-04-20 02:55:58 +00:00
|
|
|
(2 `(face org-checkbox keymap ,org-mouse-map mouse-face highlight) t)))
|
2021-03-30 14:19:06 +00:00
|
|
|
t))
|
|
|
|
|
|
|
|
(defadvice org-open-at-point (around org-mouse-open-at-point activate)
|
|
|
|
(let ((context (org-context)))
|
|
|
|
(cond
|
|
|
|
((assq :headline-stars context) (org-cycle))
|
|
|
|
((assq :checkbox context) (org-toggle-checkbox))
|
|
|
|
((assq :item-bullet context)
|
|
|
|
(let ((org-cycle-include-plain-lists t)) (org-cycle)))
|
|
|
|
((org-footnote-at-reference-p) nil)
|
|
|
|
(t ad-do-it))))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
2016-06-21 21:12:23 +00:00
|
|
|
(defun org-mouse-move-tree-start (_event)
|
2008-01-31 10:32:52 +00:00
|
|
|
(interactive "e")
|
|
|
|
(message "Same line: promote/demote, (***):move before, (text): make a child"))
|
|
|
|
|
|
|
|
|
|
|
|
(defun org-mouse-make-marker (position)
|
|
|
|
(with-current-buffer (window-buffer (posn-window position))
|
|
|
|
(copy-marker (posn-point position))))
|
|
|
|
|
|
|
|
(defun org-mouse-move-tree (event)
|
|
|
|
;; todo: handle movements between different buffers
|
|
|
|
(interactive "e")
|
|
|
|
(save-excursion
|
|
|
|
(let* ((start (org-mouse-make-marker (event-start event)))
|
|
|
|
(end (org-mouse-make-marker (event-end event)))
|
|
|
|
(sbuf (marker-buffer start))
|
|
|
|
(ebuf (marker-buffer end)))
|
|
|
|
|
2012-08-11 17:10:44 +00:00
|
|
|
(when (and sbuf ebuf)
|
|
|
|
(set-buffer sbuf)
|
|
|
|
(goto-char start)
|
|
|
|
(org-back-to-heading)
|
|
|
|
(if (and (eq sbuf ebuf)
|
|
|
|
(equal
|
|
|
|
(point)
|
|
|
|
(save-excursion (goto-char end) (org-back-to-heading) (point))))
|
|
|
|
;; if the same line then promote/demote
|
|
|
|
(if (>= end start) (org-demote-subtree) (org-promote-subtree))
|
|
|
|
;; if different lines then move
|
|
|
|
(org-cut-subtree)
|
|
|
|
|
|
|
|
(set-buffer ebuf)
|
|
|
|
(goto-char end)
|
|
|
|
(org-back-to-heading)
|
|
|
|
(when (and (eq sbuf ebuf)
|
|
|
|
(equal
|
|
|
|
(point)
|
|
|
|
(save-excursion (goto-char start)
|
|
|
|
(org-back-to-heading) (point))))
|
2014-05-23 11:11:57 +00:00
|
|
|
(progn (org-end-of-subtree nil t)
|
|
|
|
(unless (eobp) (backward-char)))
|
2008-01-31 10:32:52 +00:00
|
|
|
(end-of-line)
|
2012-08-11 17:10:44 +00:00
|
|
|
(if (eobp) (newline) (forward-char)))
|
|
|
|
|
|
|
|
(when (looking-at org-outline-regexp)
|
|
|
|
(let ((level (- (match-end 0) (match-beginning 0))))
|
|
|
|
(when (> end (match-end 0))
|
2014-05-23 11:11:57 +00:00
|
|
|
(progn (org-end-of-subtree nil t)
|
|
|
|
(unless (eobp) (backward-char)))
|
2012-08-11 17:10:44 +00:00
|
|
|
(end-of-line)
|
|
|
|
(if (eobp) (newline) (forward-char))
|
|
|
|
(setq level (1+ level)))
|
|
|
|
(org-paste-subtree level)
|
|
|
|
(save-excursion
|
2014-05-23 11:11:57 +00:00
|
|
|
(progn (org-end-of-subtree nil t)
|
|
|
|
(unless (eobp) (backward-char)))
|
2012-08-11 17:10:44 +00:00
|
|
|
(when (bolp) (delete-char -1))))))))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defun org-mouse-transform-to-outline ()
|
|
|
|
(interactive)
|
|
|
|
(org-back-to-heading)
|
|
|
|
(let ((minlevel 1000)
|
|
|
|
(replace-text (concat (match-string 0) "* ")))
|
|
|
|
(beginning-of-line 2)
|
|
|
|
(save-excursion
|
Don't use `outline-regexp' anymore.
Use `org-outline-regexp' instead or `outline-regexp'. Also use the
new defconst `org-outline-regexp-bol' to match `org-outline-regexp'
at the beginning of line.
* org.el (org-outline-regexp-bol): New defconst.
(org-outline-level, org-set-font-lock-defaults, org-cycle)
(org-overview, org-content, org-flag-drawer)
(org-first-headline-recenter, org-insert-todo-heading)
(org-map-region, org-move-subtree-down, org-paste-subtree)
(org-kill-is-subtree-p, org-context-p, org-refile)
(org-refile-new-child, org-toggle-comment, org-todo)
(org-add-planning-info, org-add-log-setup, org-scan-tags)
(org-set-tags, org-insert-property-drawer)
(org-prepare-agenda-buffers, org-preview-latex-fragment)
(org-speed-command-default-hook, org-check-for-hidden)
(org-toggle-item, org-toggle-heading)
(org-indent-line-function, org-set-autofill-regexps)
(org-fill-paragraph, org-toggle-fixed-width-section)
(org-yank-generic, org-yank-folding-would-swallow-text)
(org-first-sibling-p, org-goto-sibling)
(org-goto-first-child, org-show-entry): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-remember.el (org-remember-handler): Use
`org-outline-regexp-bol'.
* org-mouse.el (org-mouse-match-todo-keyword, org-mode-hook)
(org-mouse-move-tree, org-mouse-transform-to-outline): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-macs.el (org-with-limited-levels)
(org-get-limited-outline-regexp): Use `org-outline-regexp'.
* org-indent.el (org-indent-outline-re)
(org-indent-refresh-section, org-indent-refresh-to): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-html.el (org-export-as-html): Use
`org-outline-regexp-bol'.
* org-footnote.el (org-footnote-at-definition-p)
(org-footnote-normalize): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-exp.el (org-export-preprocess-string): Don't redefine
`outline-regexp'.
* org-docbook.el (org-export-as-docbook): Use
`org-outline-regexp-bol'.
* org-colview.el (org-columns, org-columns-compute): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-colview-xemacs.el (org-columns, org-columns-compute):
Use `org-outline-regexp-bol'.
* org-clock.el (org-clock-insert-selection-line)
(org-clock-in, org-clock-out, org-dblock-write:clocktable):
Use `org-outline-regexp' and `org-outline-regexp-bol'.
* org-ascii.el (org-export-as-ascii)
(org-export-ascii-push-links): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-archive.el (org-archive-to-archive-sibling)
(org-archive-all-done): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-agenda.el (org-agenda, org-search-view)
(org-agenda-list-stuck-projects, org-agenda-get-timestamps)
(org-agenda-get-progress, org-agenda-get-blocks): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
2011-07-17 19:17:08 +00:00
|
|
|
(while (not (or (eobp) (looking-at org-outline-regexp)))
|
2008-01-31 10:32:52 +00:00
|
|
|
(when (looking-at org-mouse-plain-list-regexp)
|
|
|
|
(setq minlevel (min minlevel (- (match-end 1) (match-beginning 1)))))
|
|
|
|
(forward-line)))
|
Don't use `outline-regexp' anymore.
Use `org-outline-regexp' instead or `outline-regexp'. Also use the
new defconst `org-outline-regexp-bol' to match `org-outline-regexp'
at the beginning of line.
* org.el (org-outline-regexp-bol): New defconst.
(org-outline-level, org-set-font-lock-defaults, org-cycle)
(org-overview, org-content, org-flag-drawer)
(org-first-headline-recenter, org-insert-todo-heading)
(org-map-region, org-move-subtree-down, org-paste-subtree)
(org-kill-is-subtree-p, org-context-p, org-refile)
(org-refile-new-child, org-toggle-comment, org-todo)
(org-add-planning-info, org-add-log-setup, org-scan-tags)
(org-set-tags, org-insert-property-drawer)
(org-prepare-agenda-buffers, org-preview-latex-fragment)
(org-speed-command-default-hook, org-check-for-hidden)
(org-toggle-item, org-toggle-heading)
(org-indent-line-function, org-set-autofill-regexps)
(org-fill-paragraph, org-toggle-fixed-width-section)
(org-yank-generic, org-yank-folding-would-swallow-text)
(org-first-sibling-p, org-goto-sibling)
(org-goto-first-child, org-show-entry): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-remember.el (org-remember-handler): Use
`org-outline-regexp-bol'.
* org-mouse.el (org-mouse-match-todo-keyword, org-mode-hook)
(org-mouse-move-tree, org-mouse-transform-to-outline): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-macs.el (org-with-limited-levels)
(org-get-limited-outline-regexp): Use `org-outline-regexp'.
* org-indent.el (org-indent-outline-re)
(org-indent-refresh-section, org-indent-refresh-to): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-html.el (org-export-as-html): Use
`org-outline-regexp-bol'.
* org-footnote.el (org-footnote-at-definition-p)
(org-footnote-normalize): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-exp.el (org-export-preprocess-string): Don't redefine
`outline-regexp'.
* org-docbook.el (org-export-as-docbook): Use
`org-outline-regexp-bol'.
* org-colview.el (org-columns, org-columns-compute): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-colview-xemacs.el (org-columns, org-columns-compute):
Use `org-outline-regexp-bol'.
* org-clock.el (org-clock-insert-selection-line)
(org-clock-in, org-clock-out, org-dblock-write:clocktable):
Use `org-outline-regexp' and `org-outline-regexp-bol'.
* org-ascii.el (org-export-as-ascii)
(org-export-ascii-push-links): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-archive.el (org-archive-to-archive-sibling)
(org-archive-all-done): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-agenda.el (org-agenda, org-search-view)
(org-agenda-list-stuck-projects, org-agenda-get-timestamps)
(org-agenda-get-progress, org-agenda-get-blocks): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
2011-07-17 19:17:08 +00:00
|
|
|
(while (not (or (eobp) (looking-at org-outline-regexp)))
|
2008-01-31 10:32:52 +00:00
|
|
|
(when (and (looking-at org-mouse-plain-list-regexp)
|
|
|
|
(eq minlevel (- (match-end 1) (match-beginning 1))))
|
|
|
|
(replace-match replace-text))
|
|
|
|
(forward-line))))
|
2008-01-31 10:36:18 +00:00
|
|
|
|
2012-03-30 19:48:15 +00:00
|
|
|
(defvar org-mouse-cmd) ;dynamically scoped from `org-with-remote-undo'.
|
2008-01-31 10:36:18 +00:00
|
|
|
|
2008-01-31 10:32:52 +00:00
|
|
|
(defun org-mouse-do-remotely (command)
|
2016-06-21 21:12:23 +00:00
|
|
|
;; (org-agenda-check-no-diary)
|
2008-01-31 10:32:52 +00:00
|
|
|
(when (get-text-property (point) 'org-marker)
|
|
|
|
(let* ((anticol (- (point-at-eol) (point)))
|
|
|
|
(marker (get-text-property (point) 'org-marker))
|
|
|
|
(buffer (marker-buffer marker))
|
|
|
|
(pos (marker-position marker))
|
|
|
|
(hdmarker (get-text-property (point) 'org-hd-marker))
|
|
|
|
(buffer-read-only nil)
|
|
|
|
(newhead "--- removed ---")
|
|
|
|
(org-mouse-direct nil)
|
|
|
|
(org-mouse-main-buffer (current-buffer)))
|
|
|
|
(when (eq (with-current-buffer buffer major-mode) 'org-mode)
|
2009-11-05 21:51:50 +00:00
|
|
|
(let ((endmarker (with-current-buffer buffer
|
2014-05-23 11:11:57 +00:00
|
|
|
(org-end-of-subtree nil t)
|
|
|
|
(unless (eobp) (forward-char 1))
|
2014-06-22 05:43:58 +00:00
|
|
|
(point-marker))))
|
2008-01-31 10:33:46 +00:00
|
|
|
(org-with-remote-undo buffer
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(widen)
|
|
|
|
(goto-char pos)
|
|
|
|
(org-show-hidden-entry)
|
|
|
|
(save-excursion
|
|
|
|
(and (outline-next-heading)
|
|
|
|
(org-flag-heading nil))) ; show the next heading
|
|
|
|
(org-back-to-heading)
|
2014-06-22 05:43:58 +00:00
|
|
|
(setq marker (point-marker))
|
2008-01-31 10:33:46 +00:00
|
|
|
(goto-char (max (point-at-bol) (- (point-at-eol) anticol)))
|
|
|
|
(funcall command)
|
2012-03-30 19:48:15 +00:00
|
|
|
(message "_cmd: %S" org-mouse-cmd)
|
2008-01-31 10:33:46 +00:00
|
|
|
(message "this-command: %S" this-command)
|
|
|
|
(unless (eq (marker-position marker) (marker-position endmarker))
|
|
|
|
(setq newhead (org-get-heading))))
|
2008-04-24 08:29:47 +00:00
|
|
|
|
2008-01-31 10:33:46 +00:00
|
|
|
(beginning-of-line 1)
|
2008-01-31 10:32:52 +00:00
|
|
|
(save-excursion
|
2008-01-31 10:33:46 +00:00
|
|
|
(org-agenda-change-all-lines newhead hdmarker 'fixface))))
|
2008-01-31 10:32:52 +00:00
|
|
|
t))))
|
|
|
|
|
2016-06-21 21:12:23 +00:00
|
|
|
(defun org-mouse-agenda-context-menu (&optional _event)
|
2008-01-31 10:32:52 +00:00
|
|
|
(or (org-mouse-do-remotely 'org-mouse-context-menu)
|
2008-04-24 08:29:47 +00:00
|
|
|
(popup-menu
|
2008-01-31 10:32:52 +00:00
|
|
|
'("Agenda"
|
|
|
|
("Agenda Files")
|
|
|
|
"--"
|
2008-01-31 10:33:46 +00:00
|
|
|
["Undo" (progn (message "last command: %S" last-command) (setq this-command 'org-agenda-undo) (org-agenda-undo))
|
2008-04-24 08:29:47 +00:00
|
|
|
:visible (if (eq last-command 'org-agenda-undo)
|
2008-01-31 10:33:46 +00:00
|
|
|
org-agenda-pending-undo-list
|
|
|
|
org-agenda-undo-list)]
|
2008-01-31 10:32:52 +00:00
|
|
|
["Rebuild Buffer" org-agenda-redo t]
|
2008-04-24 08:29:47 +00:00
|
|
|
["New Diary Entry"
|
2017-08-30 12:22:28 +00:00
|
|
|
org-agenda-diary-entry (org-agenda-check-type nil 'agenda) t]
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
2008-04-24 08:29:47 +00:00
|
|
|
["Goto Today" org-agenda-goto-today
|
2017-08-30 12:22:28 +00:00
|
|
|
(org-agenda-check-type nil 'agenda) t]
|
2008-04-24 08:29:47 +00:00
|
|
|
["Display Calendar" org-agenda-goto-calendar
|
2017-08-30 12:22:28 +00:00
|
|
|
(org-agenda-check-type nil 'agenda) t]
|
2008-01-31 10:32:52 +00:00
|
|
|
("Calendar Commands"
|
2008-04-24 08:29:47 +00:00
|
|
|
["Phases of the Moon" org-agenda-phases-of-moon
|
2017-08-30 12:22:28 +00:00
|
|
|
(org-agenda-check-type nil 'agenda)]
|
2008-04-24 08:29:47 +00:00
|
|
|
["Sunrise/Sunset" org-agenda-sunrise-sunset
|
2017-08-30 12:22:28 +00:00
|
|
|
(org-agenda-check-type nil 'agenda)]
|
2008-04-24 08:29:47 +00:00
|
|
|
["Holidays" org-agenda-holidays
|
2017-08-30 12:22:28 +00:00
|
|
|
(org-agenda-check-type nil 'agenda)]
|
2008-04-24 08:29:47 +00:00
|
|
|
["Convert" org-agenda-convert-date
|
2017-08-30 12:22:28 +00:00
|
|
|
(org-agenda-check-type nil 'agenda)]
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
2013-04-10 13:22:56 +00:00
|
|
|
["Create iCalendar file" org-icalendar-combine-agenda-files t])
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
2008-04-24 08:29:47 +00:00
|
|
|
["Day View" org-agenda-day-view
|
2008-01-31 10:32:52 +00:00
|
|
|
:active (org-agenda-check-type nil 'agenda)
|
org-agenda: rework ndays and span handling
* org-agenda.el (org-agenda-custom-commands-local-options):
Allow org-agenda-span to be a symbol.
(org-agenda-ndays): Make obsolete.
(org-agenda-span): New variable superseding org-agenda-ndays.
(org-agenda-menu): Use org-agenda-current-span.
(org-agenda-current-span): New local variable storing current
span.
(org-agenda-list): Take a span instead of ndays as argument.
This function is now responsible for computing the ndays based
on span.
(org-agenda-ndays-to-span): Return span only if number of days
really matches.
(org-agenda-span-to-ndays): New function.
(org-agenda-manipulate-query): Use org-agenda-compute-starting-span.
(org-agenda-goto-today): Use org-agenda-compute-starting-span.
(org-agenda-later): Do not give compute a new span, use the
current one.
(org-agenda-day-view, org-agenda-week-view)
(org-agenda-month-view, org-agenda-year-view): Stop touching
org-agenda-ndays.
(org-agenda-change-time-span): Only compute starting-span.
(org-agenda-compute-starting-span): New function derived from
the old org-agenda-compute-time-span.
(org-agenda-set-mode-name): Compute mode based on
org-agenda-current-span.
(org-agenda-span-name): New function.
* org-mouse.el: Replace Replace org-agenda-ndays by
org-agenda-current-span.
* org.texi, orgguide.texi: Replace org-agenda-ndays by
org-agenda-span. Add a paragraph about org-agenda-span and say that
org-agenda-ndays is now deprecated.
This patch is pretty huge, so I'll give a bit of context about it.
I'm weird, but I used org-agenda-ndays set to 14. Unfortunately, this
settings was interpreted as a month view. Pressing 'f' key to see later,
would show me the next month, which was not at all what I wanted.
On the same idea, day view or week view would change my org-agenda-ndays
settings, which I think is not a good idea. Changing user setting is *bad*.
:-)
So I rewrote the things this way:
- Rename org-agenda-span to org-agenda-current-span
Which has the same meaning has before, except it can be numeric.
- Rename org-agenda-ndays to org-agenda-span
I think the name is better choosen. You can set it to a symbol instead of
only a numeric value. That means you can set it to 'month and it will show
you the number of days of the current month in your agenda. Better than
30. But you can still set it to 30, or 31, or whatever you want.
- Do not change org-agenda-span. Never.
- Use org-agenda-current-span for navigation.
That means if you press 'f', it will shows you really the next
org-agenda-current-span ndays, and not something based on "I think you
want a weekly view".
2010-12-03 16:50:50 +00:00
|
|
|
:style radio :selected (eq org-agenda-current-span 'day)]
|
2008-04-24 08:29:47 +00:00
|
|
|
["Week View" org-agenda-week-view
|
2008-01-31 10:32:52 +00:00
|
|
|
:active (org-agenda-check-type nil 'agenda)
|
org-agenda: rework ndays and span handling
* org-agenda.el (org-agenda-custom-commands-local-options):
Allow org-agenda-span to be a symbol.
(org-agenda-ndays): Make obsolete.
(org-agenda-span): New variable superseding org-agenda-ndays.
(org-agenda-menu): Use org-agenda-current-span.
(org-agenda-current-span): New local variable storing current
span.
(org-agenda-list): Take a span instead of ndays as argument.
This function is now responsible for computing the ndays based
on span.
(org-agenda-ndays-to-span): Return span only if number of days
really matches.
(org-agenda-span-to-ndays): New function.
(org-agenda-manipulate-query): Use org-agenda-compute-starting-span.
(org-agenda-goto-today): Use org-agenda-compute-starting-span.
(org-agenda-later): Do not give compute a new span, use the
current one.
(org-agenda-day-view, org-agenda-week-view)
(org-agenda-month-view, org-agenda-year-view): Stop touching
org-agenda-ndays.
(org-agenda-change-time-span): Only compute starting-span.
(org-agenda-compute-starting-span): New function derived from
the old org-agenda-compute-time-span.
(org-agenda-set-mode-name): Compute mode based on
org-agenda-current-span.
(org-agenda-span-name): New function.
* org-mouse.el: Replace Replace org-agenda-ndays by
org-agenda-current-span.
* org.texi, orgguide.texi: Replace org-agenda-ndays by
org-agenda-span. Add a paragraph about org-agenda-span and say that
org-agenda-ndays is now deprecated.
This patch is pretty huge, so I'll give a bit of context about it.
I'm weird, but I used org-agenda-ndays set to 14. Unfortunately, this
settings was interpreted as a month view. Pressing 'f' key to see later,
would show me the next month, which was not at all what I wanted.
On the same idea, day view or week view would change my org-agenda-ndays
settings, which I think is not a good idea. Changing user setting is *bad*.
:-)
So I rewrote the things this way:
- Rename org-agenda-span to org-agenda-current-span
Which has the same meaning has before, except it can be numeric.
- Rename org-agenda-ndays to org-agenda-span
I think the name is better choosen. You can set it to a symbol instead of
only a numeric value. That means you can set it to 'month and it will show
you the number of days of the current month in your agenda. Better than
30. But you can still set it to 30, or 31, or whatever you want.
- Do not change org-agenda-span. Never.
- Use org-agenda-current-span for navigation.
That means if you press 'f', it will shows you really the next
org-agenda-current-span ndays, and not something based on "I think you
want a weekly view".
2010-12-03 16:50:50 +00:00
|
|
|
:style radio :selected (eq org-agenda-current-span 'week)]
|
2008-01-31 10:32:52 +00:00
|
|
|
"--"
|
|
|
|
["Show Logbook entries" org-agenda-log-mode
|
2008-04-24 08:29:47 +00:00
|
|
|
:style toggle :selected org-agenda-show-log
|
2017-08-30 12:22:28 +00:00
|
|
|
:active (org-agenda-check-type nil 'agenda)]
|
2008-01-31 10:32:52 +00:00
|
|
|
["Include Diary" org-agenda-toggle-diary
|
2008-04-24 08:29:47 +00:00
|
|
|
:style toggle :selected org-agenda-include-diary
|
2008-01-31 10:32:52 +00:00
|
|
|
:active (org-agenda-check-type nil 'agenda)]
|
|
|
|
["Use Time Grid" org-agenda-toggle-time-grid
|
|
|
|
:style toggle :selected org-agenda-use-time-grid
|
|
|
|
:active (org-agenda-check-type nil 'agenda)]
|
|
|
|
["Follow Mode" org-agenda-follow-mode
|
|
|
|
:style toggle :selected org-agenda-follow-mode]
|
|
|
|
"--"
|
|
|
|
["Quit" org-agenda-quit t]
|
|
|
|
["Exit and Release Buffers" org-agenda-exit t]
|
|
|
|
))))
|
|
|
|
|
2008-01-31 10:33:13 +00:00
|
|
|
(defun org-mouse-get-gesture (event)
|
|
|
|
(let ((startxy (posn-x-y (event-start event)))
|
|
|
|
(endxy (posn-x-y (event-end event))))
|
|
|
|
(if (< (car startxy) (car endxy)) :right :left)))
|
|
|
|
|
|
|
|
|
2012-08-11 17:10:44 +00:00
|
|
|
; (setq org-agenda-mode-hook nil)
|
2011-06-14 19:51:13 +00:00
|
|
|
(defvar org-agenda-mode-map)
|
2008-04-24 08:29:47 +00:00
|
|
|
(add-hook 'org-agenda-mode-hook
|
2016-07-25 13:44:49 +00:00
|
|
|
(lambda ()
|
|
|
|
(setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu)
|
|
|
|
(org-defkey org-agenda-mode-map [mouse-3] 'org-mouse-show-context-menu)
|
|
|
|
(org-defkey org-agenda-mode-map [down-mouse-3] 'org-mouse-move-tree-start)
|
|
|
|
(org-defkey org-agenda-mode-map [C-mouse-4] 'org-agenda-earlier)
|
|
|
|
(org-defkey org-agenda-mode-map [C-mouse-5] 'org-agenda-later)
|
|
|
|
(org-defkey org-agenda-mode-map [drag-mouse-3]
|
|
|
|
(lambda (event) (interactive "e")
|
|
|
|
(cl-case (org-mouse-get-gesture event)
|
|
|
|
(:left (org-agenda-earlier 1))
|
|
|
|
(:right (org-agenda-later 1)))))))
|
2008-01-31 10:32:52 +00:00
|
|
|
|
|
|
|
(provide 'org-mouse)
|
2008-03-04 12:04:31 +00:00
|
|
|
|
2010-07-16 21:23:01 +00:00
|
|
|
;;; org-mouse.el ends here
|