annotate lisp/textmodes/org.el @ 61512:46263849dcce

*** empty log message ***
author Luc Teirlinck <teirllm@auburn.edu>
date Tue, 12 Apr 2005 22:58:19 +0000
parents 6939a6683ac3
children a54fc673c31c 02f1dbc4a199
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; org.el --- Outline-based notes management and organizer
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2 ;; Carstens outline-mode for keeping track of everything.
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3 ;; Copyright (c) 2004, 2005 Free Software Foundation
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4 ;;
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Carsten Dominik <dominik at science dot uva dot nl>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: outlines, hypermedia, calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
8 ;; Version: 3.05
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
9 ;;
58794
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
10 ;; This file is part of GNU Emacs.
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
11 ;;
58794
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
58794
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7cae75ad3466 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 58792
diff changeset
20 ;; GNU General Public License for more details.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; project planning with a fast and effective plain-text system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; Org-mode develops organizational tasks around a NOTES file that contains
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; information about projects as plain text. Org-mode is implemented on
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; top of outline-mode - ideal to keep the content of large files well
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; structured. It supports ToDo items, deadlines and time stamps, which
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; magically appear in the diary listing of the Emacs calendar. Tables are
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; easily created with a built-in table editor. Plain text URL-like links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; connect to websites, emails (VM,RMAIL,WANDERLUST), Usenet messages (Gnus),
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; BBDB entries, and any files related to the projects. For printing and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; sharing of notes, an Org-mode file (or a part of it) can be exported as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; a structured ASCII file, or as HTML.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; Installation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; ------------
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; The instruction below assume that you have downloaded Org-mode from the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; web. If Org-mode is part of the Emacs distribution or an XEmacs package,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; you only need to add to .emacs the last three lines of Lisp code listed
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; below, i.e. the `auto-mode-alist' modification and the global key bindings.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Byte-compile org.el and put it on your load path. Then copy the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; following lines into .emacs. The last two lines define *global*
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; keys for the commands `org-store-link' and `org-agenda' - please
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; choose suitable keys yourself.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; (autoload 'org-mode "org" "Org mode" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; (autoload 'org-diary "org" "Diary entries from Org mode")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; (autoload 'org-store-link "org" "Store a link to the current location" t)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
60 ;; (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
61 ;; (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; (define-key global-map "\C-cl" 'org-store-link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; (define-key global-map "\C-ca" 'org-agenda)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; This will put all files with extension ".org" into Org-mode. As an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; alternative, make the first line of a file look like this:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; MY PROJECTS -*- mode: org; -*-
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; which will select Org-mode for this buffer no matter what the file's
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; name is.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; Documentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; -------------
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; The documentation of Org-mode can be found in the TeXInfo file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; This distribution also contains a PDF version of it. At the homepage
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
78 ;; of Org-mode, you can read online the same text online as HTML.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; Changes:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; -------
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
82 ;; Version 3.05
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
83 ;; - Agenda entries from the diary are linked to the diary file, so
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
84 ;; adding and editing diary entries can be done directly from the agenda.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
85 ;; - Many calendar/diary commands available directly from agenda.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
86 ;; - Field copying in tables with S-RET does increment.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
87 ;; - C-c C-x C-v extracts the visible part of the buffer for printing.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
88 ;; - Moving subtrees up and down preserves the whitespace at the tree end.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
89 ;;
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
90 ;; Version 3.04
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
91 ;; - Table editor optimized to need fewer realignments, and to keep
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
92 ;; table shape when typing in fields.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
93 ;; - A new minor mode, orgtbl-mode, introduces the Org-mode table editor
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
94 ;; into arbitrary major modes.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
95 ;; - Fixed bug with realignment in XEmacs.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
96 ;; - Startup options can be set with special #+STARTUP line.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
97 ;; - Heading following a match in org-occur can be suppressed.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
98 ;;
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; Version 3.03
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; - Copyright transfer to the FSF.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
101 ;; - Effect of C-u and C-u C-u in org-timeline swapped.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; - Timeline now always contains today, and `.' jumps to it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; - Table editor:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; - cut and paste of regtangular regions in tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; - command to convert org-mode table to table.el table and back
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; - command to treat several cells like a paragraph and fill it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; - command to convert a buffer region to a table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; - import/export tables as tab-separated files (exchange with Excel)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; - Agenda:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; - Sorting mechanism for agenda items rewritten from scratch.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;; - Sorting fully configurable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; - Entries specifying a time are sorted together.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; - Completion also covers option keywords after `#-'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; - Bug fixes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; Version 3.01
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; - New reference card, thanks to Philip Rooke for creating it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; - Single file agenda renamed to "Timeline". It no longer shows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; warnings about upcoming deadlines/overdue scheduled items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; That functionality is now limited to the (multifile) agenda.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; - When reading a date, the calendar can be manipulated with keys.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; - Link support for RMAIL and Wanderlust (from planner.el, untested)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; - Minor bug fixes and documentation improvements.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; Version 3.00
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; - Multifile Agenda shows current entries from many different files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; - TeXInfo documentation (thanks to Christian Egli for the conversion).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; - Additional applications for TODO keywords, see documentation.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; Different files may have different TODO keywords etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; - Priorities for TODO items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; - The browser mode used by `org-remember-handler' is improved.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; - Images get inlined in HTML export (thanks to Carsten Wimmer).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; - File links can contain line numbers, like file:/usr/etc/config:255
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;; - Minor bug fixes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; Version 2.10
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; - TODO entries can have additional states besides TODO and DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; See new variable `org-todo-keywords'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; - TODO keywords can be interpreted as categories. See variable
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; `org-todo-interpretation'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; - M-TAB completion on TODO keywords, TeX symbols, and normal words.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;; - All keywords (like TODO, DEADLINE etc) are configurable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; - Cursor positioning optimized after pro/demotion and TODO cycling.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;; - Emphasizing in HTML works now for *bold*, /italic/ and _underline_.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; - New commands to kill, copy and yank entire subtrees. Yanking
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; modifies the level of the tree before insertion.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; - New command `org-goto' (C-c C-j) to quickly move to other locations
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;; in the buffer without affecting outline visibility.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; - Hooks for John Wiegley's remember.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; - `org-read-date' pops up calendar for date selection with the mouse.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; See variable `org-popup-calendar-for-date-prompt'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; Version 2.6
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; - TODO items can be SCHEDULED to a certain date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;; - Expired DEADLINEs are ignored if in an entry marked DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;; - From the diary or time-sorted view (C-c C-r), C-c C-t can be used to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; change the TODO state of an item remotely.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; - Horizontal computations in table editor. See `org-table-eval-formula'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;; - Fixed bug with summing tables (command `org-table-sum', `C-c +').
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ;; - Calendar window follows the timestamp when a timestamp is changed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; New variable `org-calendar-follow-timestamp-change'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; - Time-sorted view (`org-diary-view', C-c C-r) now uses the prefix
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;; argument to force inclusion of unscheduled TODO items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; - New variable `org-confirm-shell-links' to turn of safety query.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;; - New variable `org-open-non-existing-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 ;; Version 2.4
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;; - A time-sorted view on all time stamps can be created with C-c C-r.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;; - Timestamps and Deadlines can be shown in the Emacs diary.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; - Date ranges introduced.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;; - Time-string formats are no longer configurable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; - Vertical lines in tables can be made invisible with `C-c |'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;; - New "link" type to execute shell commands, like "shell:ls *.org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ;; - Upon export, "myfile.org" becomes "myfile.html" or "myfile.txt",
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ;; instead of "myfile.org.html" or "myfile.org.txt".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ;; - When the cursor is in the white space at the beginning of a line,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;; TAB removes the whitespace before indenting again.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ;; Version 2.0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;; - Windows (NT/2000) support.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;; - Works with both Emacs and XEmacs.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; - Fully automatic table editor.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; - New link types into Gnus, VM and BBDB.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;; - Other link system changes
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;; - Time stamps are treated as links to the calendar.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;; - Easy creation of links with global command `org-store-link'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;; - Insertion of links with `C-c C-l' works differently now.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; - Space characters allowed as part of a link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;; - Options in `org-file-apps' extended. The command may now be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;; symbol 'emacs', or a lisp form.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ;; Please re-read the manual section about links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;; - Timestamp changes
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; - `org-deadline' now prompts for a date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;; - A line can now contain several timestamps. Updating of a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;; timestamp only happens if the cursor is at the timestamp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;; - Changed the time-stamp-format to ISO, to make sure it will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ;; always work (non-English month names had caused problems
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ;; with `parse-time-string'.). Changing the time stamp format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 ;; is not recommended.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ;; - Picture mode enhancements have been removed from org.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 ;; Version 1.4
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 ;; - Some option name changes, not backward compatible.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 ;; - ASCII exporter upgrade: Table of contents.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 ;; - HTML exporter upgrade: fixed-width regions, better
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 ;; sub/superscripts, many TeX symbols supported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 ;; - Calendar support.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ;; Version 1.3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;; - HTML exporter upgrade, in particular table of contents
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;; Version 1.0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 ;; - Initial release
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 ;;; Code:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (eval-when-compile (require 'cl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (require 'outline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (require 'time-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (require 'easymenu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 ;;; Customization variables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
224 (defvar org-version "3.05"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 "The version number of the file org.el.")
59596
8e7a2f6f9fa7 (org-version): Unnecessary prefix arg removed.
Carsten Dominik <dominik@science.uva.nl>
parents: 59547
diff changeset
226 (defun org-version ()
8e7a2f6f9fa7 (org-version): Unnecessary prefix arg removed.
Carsten Dominik <dominik@science.uva.nl>
parents: 59547
diff changeset
227 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (message "Org-mode version %s" org-version))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 ;; The following two constants are for compatibility with different
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 ;; Emacs versions (Emacs versus XEmacs) and with different versions of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 ;; outline.el. All the compatibility code in org.el is based on these two
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 ;; constants.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (defconst org-xemacs-p (featurep 'xemacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 "Are we running xemacs?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (defconst org-noutline-p (featurep 'noutline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 "Are we using the new outline mode?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (defgroup org nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 "Outline-based notes management and organizer "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 :tag "Org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 :group 'outlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 :group 'hypermedia
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 :group 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (defgroup org-startup nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 "Options concerning startup of Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 :tag "Org Startup"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (defcustom org-startup-folded t
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
252 "Non-nil means, entering Org-mode will switch to OVERVIEW.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
253 This can also be configured on a per-file basis by adding one of
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
254 the following lines anywhere in the buffer:
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
255
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
256 #+STARTUP: fold
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
257 #+STARTUP: nofold
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
258 "
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (defcustom org-startup-truncated t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 "Non-nil means, entering Org-mode will set `truncate-lines'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 This is useful since some lines containing links can be very long and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 uninteresting. Also tables look terrible when wrapped."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (defcustom org-startup-with-deadline-check nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 "Non-nil means, entering Org-mode will run the deadline check.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 This means, if you start editing an org file, you will get an
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
272 immediate reminder of any due deadlines.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
273 This can also be configured on a per-file basis by adding one of
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
274 the following lines anywhere in the buffer:
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
275
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
276 #+STARTUP: dlcheck
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
277 #+STARTUP: nodlcheck
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
278 "
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281
61312
6939a6683ac3 (org-diary-default-entry): Fixed call to
Carsten Dominik <dominik@science.uva.nl>
parents: 61134
diff changeset
282 (defcustom org-insert-mode-line-in-empty-file nil
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "Non-nil means insert the first line setting Org-mode in empty files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 When the function `org-mode' is called interactively in an empty, this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 normally means that the file name does not automatically trigger Org-mode.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 To ensure that the file will always be in Org-mode in the future, a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 line enforcing Org-mode can be inserted into the buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (defgroup org-keywords nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 "Options concerning TODO items in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 :tag "Org Keywords"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (defcustom org-todo-keywords '("TODO" "DONE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 "List of TODO entry keywords.\\<org-mode-map>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 considered to mean that the entry is \"done\". All the other mean that
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 action is required, and will make the entry show up in todo lists, diaries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 The command \\[org-todo] cycles an entry through these states, and an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 additional state where no keyword is present. For details about this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 cycling, see also the variable `org-todo-interpretation'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 :type '(repeat (string :tag "Keyword")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (defcustom org-todo-interpretation 'sequence
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 "Controls how TODO keywords are interpreted.\\<org-mode-map>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 Possible values are `sequence' and `type'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 This variable is only relevant if `org-todo-keywords' contains more than two
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 states. There are two ways how these keywords can be used:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 - As a sequence in the process of working on a TODO item, for example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (setq org-todo-keywords '(\"TODO\" \"STARTED\" \"VERIFY\" \"DONE\")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 - As different types of TODO items, for example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (setq org-todo-keywords '(\"URGENT\" \"RELAXED\" \"REMIND\" \"FOR_TOM\" \"DONE\")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 org-todo-interpretation 'type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 When the states are interpreted as a sequence, \\[org-todo] always cycles
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 to the next state, in order to walk through all different states. So with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 \\[org-todo], you turn an empty entry into the state TODO. When you started
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 working on the item, you use \\[org-todo] again to switch it to \"STARTED\",
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 later to VERIFY and finally to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 When the states are interpreted as types, \\[org-todo] still cycles through
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 when it is called several times in direct succession, in order to initially
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 select the type. However, if not called immediately after a previous
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 \\[org-todo], it switches from each type directly to DONE. So with the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 above example, you could use `\\[org-todo] \\[org-todo]' to label an entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 RELAXED. If you later return to this entry and press \\[org-todo] again,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 RELAXED will not be changed REMIND, but directly to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 You can create a large number of types. To initially select a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 type, it is then best to use C-u \\[org-todo] in order to specify the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 type with completion. Of course, you can also type the keyword
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 directly into the buffer. M-TAB completes TODO keywords at the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 beginning of a headline."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 :type '(choice (const sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (const type)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (defcustom org-default-priority ?B
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 "The default priority of TODO items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 This is the priority an item get if no explicit priority is given."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 :type 'character)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (defcustom org-lowest-priority ?C
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 "The lowest priority of TODO items. A character like ?A, ?B etc."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 :type 'character)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (defcustom org-deadline-string "DEADLINE:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 "String to mark deadline entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 A deadline is this string, followed by a time stamp. Should be a word,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 terminated by a colon. You can insert a schedule keyword and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 a timestamp with \\[org-deadline].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (defcustom org-scheduled-string "SCHEDULED:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 "String to mark scheduled TODO entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 A schedule is this string, followed by a time stamp. Should be a word,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 terminated by a colon. You can insert a schedule keyword and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 a timestamp with \\[org-schedule].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (defcustom org-comment-string "COMMENT"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 "Entries starting with this keyword will never be exported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 An entry can be toggled between COMMENT and normal with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 \\[org-toggle-comment].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (defcustom org-after-todo-state-change-hook nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 "Hook which is run after the state of a TODO item was changed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 The new state (a string with a todo keyword, or nil) is available in the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 lisp variable `state'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 :type 'hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 ;; Variables for pre-computed regular expressions, all buffer local
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (defvar org-todo-kwd-priority-p nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 "Do TODO items have priorities?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (make-variable-buffer-local 'org-todo-kwd-priority-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (defvar org-todo-kwd-max-priority nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 "Maximum priority of TODO items")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (make-variable-buffer-local 'org-todo-kwd-max-priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (defvar org-ds-keyword-length 12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 "Maximum length of the Deadline and SCHEDULED keywords.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (make-variable-buffer-local 'org-ds-keyword-length)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (defvar org-done-string nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 "The last string in `org-todo-keywords', indicating an item is DONE.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (make-variable-buffer-local 'org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (defvar org-todo-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 "Matches any of the TODO state keywords.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (make-variable-buffer-local 'org-todo-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (defvar org-not-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 "Matches any of the TODO state keywords except the last one.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (make-variable-buffer-local 'org-not-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (defvar org-todo-line-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 "Matches a headline and puts TODO state into group 2 if present.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (make-variable-buffer-local 'org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (defvar orb-nl-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 "Matches newline followed by a headline with the DONE keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (make-variable-buffer-local 'orb-nl-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (defvar org-looking-at-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 "Matches the DONE keyword a point.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (make-variable-buffer-local 'org-looking-at-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (defvar org-deadline-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 "Matches the DEADLINE keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (make-variable-buffer-local 'org-deadline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (defvar org-deadline-time-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 "Matches the DEADLINE keyword together with a time stamp.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (make-variable-buffer-local 'org-deadline-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (defvar org-deadline-line-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 "Matches the DEADLINE keyword and the rest of the line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (make-variable-buffer-local 'org-deadline-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (defvar org-scheduled-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 "Matches the SCHEDULED keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (make-variable-buffer-local 'org-scheduled-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (defvar org-scheduled-time-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 "Matches the SCHEDULED keyword together with a time stamp.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (make-variable-buffer-local 'org-scheduled-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
434 (defun org-set-regexps-and-options ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 "Precompute regular expressions for current buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (when (eq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (let ((re (org-make-options-regexp
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
438 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (splitre "[ \t]+")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 kwds int key value cat)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (while (re-search-forward re nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (setq key (match-string 1) value (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 ((equal key "CATEGORY")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (setq cat (intern (car (org-split-string value splitre)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 ((equal key "SEQ_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (setq int 'sequence
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 kwds (append kwds (org-split-string value splitre))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 ((equal key "PRI_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (setq int 'priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 kwds (append kwds (org-split-string value splitre))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ((equal key "TYP_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (setq int 'type
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
458 kwds (append kwds (org-split-string value splitre))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
459 ((equal key "STARTUP")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
460 (let ((opts (org-split-string value splitre))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
461 (set '(("fold" org-startup-folded t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
462 ("nofold" org-startup-folded nil)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
463 ("dlcheck" org-startup-with-deadline-check t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
464 ("nodlcheck" org-startup-with-deadline-check nil)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
465 l var val)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
466 (while (setq l (assoc (pop opts) set))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
467 (setq var (nth 1 l) val (nth 2 l))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
468 (set (make-local-variable var) val)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (and cat (set (make-local-variable 'org-category) cat))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (and kwds (set (make-local-variable 'org-todo-keywords) kwds))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (and int (set (make-local-variable 'org-todo-interpretation) int)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 ;; Compute the regular expressions and other local variables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 org-todo-kwd-max-priority (1- (length org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 org-ds-keyword-length (+ 2 (max (length org-deadline-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (length org-scheduled-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 org-done-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (nth (1- (length org-todo-keywords)) org-todo-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 org-todo-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 "\\|") "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 org-not-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (concat "\\<\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (mapconcat 'regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (nreverse (cdr (reverse org-todo-keywords)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 org-todo-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (concat "^\\(\\*+\\)[ \t]*\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (mapconcat 'regexp-quote org-todo-keywords "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 "\\)? *\\(.*\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 orb-nl-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 org-looking-at-done-regexp (concat "^" org-done-string "\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 org-deadline-regexp (concat "\\<" org-deadline-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 org-deadline-time-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 org-deadline-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (concat "\\<\\(" org-deadline-string "\\).*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 org-scheduled-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (concat "\\<" org-scheduled-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 org-scheduled-time-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (org-set-font-lock-defaults)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (defgroup org-time nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 "Options concerning time stamps and deadlines in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 :tag "Org Time"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (defcustom org-deadline-warning-days 30
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 "No. of days before expiration during which a deadline becomes active.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 This variable governs the display in the org file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (defcustom org-popup-calendar-for-date-prompt t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 "Non-nil means, pop up a calendar when prompting for a date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 In the calendar, the date can be selected with mouse-1. However, the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 minibuffer will also be active, and you can simply enter the date as well.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 When nil, only the minibuffer will be available."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (defcustom org-calendar-follow-timestamp-change t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 "Non-nil means, make the calendar window follow timestamp changes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 When a timestamp is modified and the calendar window is visible, it will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 moved to the new date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (defgroup org-agenda nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 "Options concerning agenda display Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 :tag "Org Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (defcustom org-agenda-files nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 "A list of org files for agenda/diary display.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 Entries are added to this list with \\[org-add-file] and removed with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 \\[org-remove-file]. You can also use customize to edit the list."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 :type '(repeat file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (defcustom org-select-timeline-window t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 "Non-nil means, after creating a timeline, move cursor into Timeline window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 When nil, cursor will remain in the current window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (defcustom org-select-agenda-window t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 "Non-nil means, after creating an agenda, move cursor into Agenda window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 When nil, cursor will remain in the current window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
557 (defcustom org-fit-agenda-window t
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
558 "Non-nil means, change windo size of agenda to fit content."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
559 :group 'org-agenda
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
560 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
561
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (defcustom org-agenda-show-all-dates t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 "Non-nil means, `org-agenda' shows every day in the selected range.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 When nil, only the days which actually have entries are shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 ;; FIXME: First day of month works only for current month because it would
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 ;; require a variable ndays treatment.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (defcustom org-agenda-start-on-weekday 1
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 "Non-nil means, start the overview always on the specified weekday.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 0 Denotes Sunday, 1 denotes Monday etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 When nil, always start on the current day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 :type '(choice (const :tag "Today" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (const :tag "First day of month" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (number :tag "Weekday No.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (defcustom org-agenda-ndays 7
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 "Number of days to include in overview display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (defcustom org-agenda-include-all-todo t
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
585 "Non-nil means, the multifile agenda will always contain all TODO entries.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 When nil, date-less entries will only be shown if `org-agenda' is called
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 with a prefix argument.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 When non-nil, the TODO entries will be listed at the top of the agenda, before
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 the entries for specific days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (defcustom org-agenda-include-diary nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 "Non-nil means, when preparing the agenda, also get the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 entries from the emacs calendars diary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (defcustom org-agenda-sorting-strategy '(time-up category-keep priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 "Sorting structure for the agenda items of a single day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 This is a list of symbols which will be used in sequence to determine
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 if an entry should be listed before another entry. The following
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 symbols are recognized.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 time-up Put entries with time-of-day indications first, early first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 time-down Put entries with time-of-day indications first, late first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 category-keep Keep the default order of categories, corresponding to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 sequence in `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 category-up Sort alphabetically by category, A-Z.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 category-down Sort alphabetically by category, Z-A.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 priority-up Sort numerically by priority, high priority last.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 priority-down Sort numerically by priority, high priority first.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 The different possibilities will be tried in sequence, and testing stops
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 if one comparison returns a \"not-equal\". For example, the default
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 '(time-up category-keep priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 means: Pull out all entries having a specified time of day and sort them,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 in order to make a time schedule for the current day the first thing in the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 agenda listing for the day. Of the entries without a time indication, keep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 the grouped in categories, don't sort the categories, but keep them in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 the sequence given in `org-agenda-files'. Within each category sort by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 priority.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 Leaving out the `category-keep' would mean that items will be sorted across
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 categories by priority."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (const time-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (const time-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (const category-keep)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (const category-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (const category-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (const priority-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (const priority-down))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (defcustom org-sort-agenda-notime-is-late t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 "Non-nil means, items without time are considered late.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 This is only relevant for sorting. When t, items which have no explicit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 time like 15:30 will be considered as 24:01, i.e. later than any items which
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 do have a time. When nil, the default time is before 0:00."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (defvar org-category nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 "Variable used by org files to set a category for agenda display.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 Such files should use a file variable to set it, for example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 -*- mode: org; org-category: \"ELisp\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 If the file does not specify a category, the file's base name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 is used instead.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (defgroup org-structure nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 "Options concerning structure editing in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 :tag "Org Structure"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (defcustom org-adapt-indentation t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 "Non-nil means, adapt indentation when promoting and demoting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 When this is set and the *entire* text in an entry is indented, the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 indentation is increased by one space in a demotion command, and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 decreased by one in a promotion command. If any line in the entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 body starts at column 0, indentation is not changed at all."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 :group 'org-structure
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (defcustom org-cycle-emulate-tab t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 "Where should `org-cycle' emulate TAB.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 nil Never
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 white Only in completely white lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 t Everywhere except in headlines"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 :group 'org-structure
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 :type '(choice (const :tag "Never" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (const :tag "Only in completely white lines" white)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (const :tag "Everywhere except in headlines" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 "Formats for `format-time-string' which are used for time stamps.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 It is not recommended to change this constant.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
684 (defcustom org-show-following-heading t
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
685 "Non-nil means, show heading following match in `org-occur'.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
686 When doing an `org-occur' it is useful to show the headline which
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
687 follows the match, even if they do not match the regexp. This makes it
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
688 easier to edit directly inside the sparse tree. However, if you use
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
689 org-occur mainly as an overview, the following headlines are
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
690 unnecessary clutter."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
691 :group 'org-structure
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
692 :type 'boolean)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
693
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
694
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
695
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (defgroup org-link nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 "Options concerning links in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 :tag "Org Link"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (defcustom org-allow-space-in-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 "Non-nil means, file names in links may contain space characters.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 When nil, it becomes possible to put several links into a line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (defcustom org-line-numbers-in-file-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 "Non-nil means, file links from `org-store-link' contain line numbers.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 The line number will be added to the file name with :NNN and interpreted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 by the command `org-open-at-point'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 negates this setting for the duration of the command."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (defcustom org-keep-stored-link-after-insertion nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 "Non-nil means, keep link in list for entire session.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 The command `org-store-link' adds a link pointing to the current
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 location to an internal list. These links accumulate during a session.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 The command `org-insert-link' can be used to insert links into any
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 Org-mode file (offering completion for all stored links). When this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 option is nil, every link which has been inserted once using `C-c C-l'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 will be removed from the list, to make completing the unused links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 more efficient."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (defcustom org-link-frame-setup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 '((vm . vm-visit-folder-other-frame)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (gnus . gnus-other-frame)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (file . find-file-other-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 "Setup the frame configuration for following links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 When following a link with Emacs, it may often be useful to display
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 this link in another window or frame. This variable can be used to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 set this up for the different types of links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 For VM, use any of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 vm-visit-folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 vm-visit-folder-other-frame
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 For Gnus, use any of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 gnus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 gnus-other-frame
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 For FILE, use any of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 find-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 find-file-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 find-file-other-frame
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 For the calendar, use the variable `calendar-setup'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 For BBDB, it is currently only possible to display the matches in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 another window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 :type '(list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (cons (const vm)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (const vm-visit-folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 (const vm-visit-folder-other-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (const vm-visit-folder-other-frame)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (cons (const gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (const gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (const gnus-other-frame)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (cons (const file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (const find-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (const find-file-other-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (const find-file-other-frame)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (defcustom org-usenet-links-prefer-google nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 "Non-nil means, `org-store-link' will create web links to google groups.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 When nil, Gnus will be used for such links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 negates this setting for the duration of the command."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 (defcustom org-open-non-existing-files nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 "Non-nil means, `org-open-file' will open non-existing file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 When nil, an error will be generated."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 (defcustom org-confirm-shell-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 "Non-nil means, ask for confirmation before executing shell links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 The default is true, to keep new users from shooting into their own foot."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 (defconst org-file-apps-defaults-linux
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 '((t . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 ("jpg" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 ("gif" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 ("ppm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 ("pgm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 ("pbm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 ("tif" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 ("png" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 ("ps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 ("ps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 ("eps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 ("eps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 ("dvi" . "xdvi %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 ("mpeg" . "plaympeg %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 ("mp3" . "plaympeg %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 ("fig" . "xfig %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 ("pdf" . "acroread %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 ("doc" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 ("ppt" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 ("pps" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 ("html" . "netscape -remote openURL(%s,new-window)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 ("htm" . "netscape -remote openURL(%s,new-window)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 ("xs" . "soffice %s"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 "Default file applications on a UNIX/LINUX system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (defconst org-file-apps-defaults-macosx
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 '((t . "open %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 ("ps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 ("ps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 ("eps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 ("eps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 ("dvi" . "xdvi %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 ("fig" . "xfig %s"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 "Default file applications on a MacOS X system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 The system \"open\" is known as a default, but we use X11 applications
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 for some files for which the OS does not have a good default.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (defconst org-file-apps-defaults-windowsnt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 '((t . (w32-shell-execute "open" file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 "Default file applications on a Windows NT system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 The system \"open\" is used for most files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (defcustom org-file-apps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 '(
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 ("txt" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 ("tex" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 ("ltx" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 ("org" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 ("el" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 "External applications for opening `file:path' items in a document.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 Org-mode uses system defaults for different file types, but
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 you can use this variable to set the application for a given file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 extension. The entries in this list are cons cells with a file extension
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 and the corresponding command. Possible values for the command are:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 `emacs' The file will be visited by the current Emacs process.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 `default' Use the default application for this file type.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 string A command to be executed by a shell. %s will be replaced
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 by the path to the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 sexp A lisp form which will be evaluated. The file path will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 be available in the lisp variable `file'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 For more examples, see the system specific constants
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 `org-file-apps-defaults-macosx'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 `org-file-apps-defaults-windowsnt'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 `org-file-apps-defaults-linux'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 (cons (string :tag "Extension")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (choice :value ""
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 (const :tag "Visit with Emacs" 'emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (const :tag "Use system default" 'default)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (string :tag "Command")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (sexp :tag "Lisp form")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (defgroup org-remember nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 "Options concerning interaction with remember.el."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 :tag "Org Remember"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 (defcustom org-directory "~/org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 "Directory with org files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 This directory will be used as default to prompt for org files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 Used by the hooks for remember.el."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 :type 'directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (defcustom org-default-notes-file "~/.notes"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 "Default target for storing notes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 Used by the hooks for remember.el. This can be a string, or nil to mean
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 the value of `remember-data-file'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (const :tag "Default from remember-data-file" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 (defcustom org-reverse-note-order nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 "Non-nil means, store new notes at the beginning of a file or entry.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 When nil, new notes will be filed to the end of a file or entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (const :tag "Reverse always" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (const :tag "Reverse never" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (repeat :tag "By file name regexp"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (cons regexp boolean))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 (defgroup org-table nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 "Options concerning tables in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 :tag "Org Table"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
902 (defcustom org-enable-table-editor 'optimized
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 "Non-nil means, lines starting with \"|\" are handled by the table editor.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
904 When nil, such lines will be treated like ordinary lines.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
905
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
906 When equal to the symbol `optimized', the table editor will be optimized to
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
907 do the following
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
908 - Use automatic overwrite mode in front of whitespace in table fields.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
909 This make the structure of the table stay in tact as long as the edited
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
910 field does not exceed the column width.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
911 - Minimize the number of realigns. Normally, the table is aligned each time
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
912 TAB or RET are pressed to move to another field. With optimization this
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
913 happens only if changes to a field might have changed the column width.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
914 Optimization requires replacing the functions `self-insert-command',
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
915 `delete-char', and `backward-delete-char' in Org-mode buffers, with a
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
916 slight (in fact: unnoticable) speed impact for normal typing. Org-mode is
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
917 very good at guessing when a re-align will be necessary, but you can always
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
918 force one with `C-c C-c'.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
919
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
920 If you would like to use the optimized version in Org-mode, but the un-optimized
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
921 version in OrgTbl-mode, see the variable `orgtbl-optimized'.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
922
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
923 This variable can be used to turn on and off the table editor during a session,
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
924 but in order to toggle optimization, a restart is required."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 :group 'org-table
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
926 :type '(choice
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
927 (const :tag "off" nil)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
928 (const :tag "on" t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
929 (const :tag "on, optimized" optimized)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (defcustom org-table-default-size "5x2"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 "The default size for newly created tables, Columns x Rows."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (defcustom org-table-automatic-realign t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 "Non-nil means, automatically re-align table when pressing TAB or RETURN.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 When nil, aligning is only done with \\[org-table-align], or after column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 removal/insertion."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (defcustom org-table-spaces-around-separators '(1 . 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 "The number of spaces to be placed before and after separators."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\"")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (defcustom org-table-spaces-around-invisible-separators '(1 . 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 "The number of spaces to be placed before and after separators.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 This option applies when the column separators have been made invisible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\"")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (defcustom org-table-number-regexp "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*$"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 "Regular expression for recognizing numbers in table columns.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 If a table column contains mostly numbers, it will be aligned to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 right. If not, it will be aligned to the left.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 The default value of this option is a regular expression which allows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 anything which looks remotely like a number as used in scientific
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 context. For example, all of the following will be considered a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 number:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 12 12.2 2.4e-08 2x10^12 4.034+-0.02 2.7(10) >3.5
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 Other options offered by the customize interface are more restrictive."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 (const :tag "Positive Integers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 "^[0-9]+$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 (const :tag "Integers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 "^[-+]?[0-9]+$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 (const :tag "Floating Point Numbers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.[0-9]*\\)$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (const :tag "Floating Point Number or Integer"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (const :tag "Exponential, Floating point, Integer"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 "^[-+]?[0-9.]+\\([eEdD][-+0-9]+\\)?$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 (const :tag "Very General Number-Like"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 (string :tag "Regexp:")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 (defcustom org-table-number-fraction 0.5
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 "Fraction of numbers in a column required to make the column align right.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 In a column all non-white fields are considered. If at least this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 fraction of fields is matched by `org-table-number-fraction',
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 alignment to the right border applies."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 (defcustom org-export-highlight-first-table-line t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 "Non-nil means, highlight the first table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 In HTML export, this means use <th> instead of <td>.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 In tables created with table.el, this applies to the first table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 In Org-mode tables, all lines before the first horizontal separator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 line will be formatted with <th> tags."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
999 (defcustom org-table-copy-increment t
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1000 "Non-nil means, increment when copying current field with \\[org-table-copy-down]."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1001 :group 'org-table
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1002 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1003
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 (defcustom org-table-tab-recognizes-table.el t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 "Non-nil means, TAB will automatically notice a table.el table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 When it sees such a table, it moves point into it and - if necessary -
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 calls `table-recognize-table'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 (defcustom org-export-prefer-native-exporter-for-tables nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 "Non-nil means, always export tables created with table.el natively.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 Natively means, use the HTML code generator in table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 When nil, Org-mode's own HTML generator is used when possible (i.e. if
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 the table does not use row- or column-spanning). This has the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 advantage, that the automatic HTML conversions for math symbols and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 sub/superscripts can be applied. Org-mode's HTML generator is also
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 much faster."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (defcustom org-enable-fixed-width-editor t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 "Non-nil means, lines starting with \":\" are treated as fixed-width.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 This currently only means, they are never auto-wrapped.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 When nil, such lines will be treated like ordinary lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 (defgroup org-export nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 "Options for exporting org-listings."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 :tag "Org Export"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (defcustom org-export-language-setup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 '(("en" "Author" "Date" "Table of Contents")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 ("da" "Ophavsmand" "Dato" "Indhold")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 ("de" "Autor" "Datum" "Inhaltsverzeichnis")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 ("es" "Autor" "Fecha" "\xccndice")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 ("fr" "Auteur" "Date" "Table des Mati\xe8res")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 ("it" "Autore" "Data" "Indice")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 ("nl" "Auteur" "Datum" "Inhoudsopgave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 "Terms used in export text, translated to different languages.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 Use the variable `org-export-default-language' to set the language,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 or use the +OPTION lines for a per-file setting."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 (string :tag "HTML language tag")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 (string :tag "Author")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 (string :tag "Date")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 (string :tag "Table of Contents"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (defcustom org-export-default-language "en"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 "The default language of HTML export, as a string.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 This should have an association in `org-export-language-setup'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 (defcustom org-export-headline-levels 3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 "The last level which is still exported as a headline.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 Inferior levels will produce itemize lists when exported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 Note that a numeric prefix argument to an exporter function overrides
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 this setting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 This option can also be set with the +OPTIONS line, e.g. \"H:2\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 (defcustom org-export-with-section-numbers t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 "Non-nil means, add section numbers to headlines when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 (defcustom org-export-with-toc t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 "Non-nil means, create a table of contents in exported files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 The TOC contains headlines with levels up to`org-export-headline-levels'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 Headlines which contain any TODO items will be marked with \"(*)\" in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 ASCII export, and with red color in HTML output.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 In HTML output, the TOC will be clickable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 (defcustom org-export-preserve-breaks nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 "Non-nil means, preserve all line breaks when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 Normally, in HTML output paragraphs will be reformatted. In ASCII
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 export, line breaks will always be preserved, regardless of this variable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 (defcustom org-export-html-inline-images t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 "Non-nil means, inline images into exported HTML pages.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 The link will still be to the original location of the image file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 So if you are moving the page, lets say to your public HTML site,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 you will have to move the image and maybe change the link."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 (defcustom org-export-html-expand t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 "Non-nil means, for HTML export, treat @<...> as HTML tag.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 When nil, these tags will be exported as plain text and therefore
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 not be interpreted by a browser.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 (defcustom org-export-with-fixed-width t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 "Non-nil means, lines starting with \":\" will be in fixed width font.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 This can be used to have preformatted text, fragments of code etc. For
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 : ;; Some Lisp examples
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 : (while (defc cnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 : (ding))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 will be looking just like this in also HTML. In ASCII export, this option
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 (defcustom org-export-with-tables t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 "Non-nil means, lines starting with \"|\" define a table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 For example:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 | Name | Address | Birthday |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 |-------------+----------+-----------|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 | Arthur Dent | England | 29.2.2100 |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 (defcustom org-export-html-table-tag
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 "<table border=1 cellspacing=0 cellpadding=6>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 "The HTML tag used to start a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 This must be a <table> tag, but you may change the options like
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 borders and spacing."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 (defcustom org-export-with-emphasize t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 "Non-nil means, interprete *word*, /word/, and _word_ as emphasized text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 If the export target supports emphasizing text, the word will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 typeset in bold, italic, or underlined, respectively. Works only for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 single words, but you can say: I *really* *mean* *this*.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 This option can also be set with the +OPTIONS line, e.g. \"*:nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (defcustom org-match-sexp-depth 3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 "Number of stacked braces for sub/superscript matching.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 This has to be set before loading org.el to be effective."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 :type 'integer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 ;; FIXME: Should () parens be removed as well in sub/superscripts?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 (defcustom org-export-with-sub-superscripts t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 "Non-nil means, interprete \"_\" and \"^\" for export.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 When this option is turned on, you can use TeX-like syntax for sub- and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 superscripts. Several characters after \"_\" or \"^\" will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 considered as a single item - so grouping with {} is normally not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 needed. For example, the following things will be parsed as single
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 sub- or superscripts.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 10^24 or 10^tau several digits will be considered 1 item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 10^-12 or 10^-tau a leading sign with digits or a word
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 x^2-y^3 will be read as x^2 - y^3, because items are
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 terminated by almost any nonword/nondigit char.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 x_{i^2} or x^(2-i) braces or parenthesis do grouping.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 Still, ambiguity is possible - so when in doubt use {} to enclose the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 sub/superscript.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 This option can also be set with the +OPTIONS line, e.g. \"^:nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (defcustom org-export-with-TeX-macros t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 "Non-nil means, interprete simple TeX-like macros when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 No only real TeX macros will work here, but the standard HTML entities
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 for math can be used as macro names as well. For a list of supported
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 names in HTML export, see the constant `org-html-entities'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 (defcustom org-export-html-with-timestamp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 "Non-nil means, write `org-export-html-html-helper-timestamp'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 into the exported html text. Otherwise, the buffer will just be saved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 to a file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 (defcustom org-export-html-html-helper-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 "<br><br><hr><p><!-- hhmts start --> <!-- hhmts end -->\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (defcustom org-export-ascii-show-new-buffer t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 "Non-nil means, popup buffer containing the exported ASCII text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 Otherwise the buffer will just be saved to a file and stay hidden."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (defcustom org-export-html-show-new-buffer nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 "Non-nil means, popup buffer containing the exported html text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 Otherwise, the buffer will just be saved to a file and stay hidden."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 (defgroup org-faces nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 "Faces for highlighting in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 :tag "Org Faces"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 (defface org-level-1-face ;; font-lock-function-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 "Face used for level 1 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 (defface org-level-2-face ;; font-lock-variable-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 '((((type tty) (class color)) (:foreground "yellow" :weight light))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (((class color) (background light)) (:foreground "DarkGoldenrod"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (((class color) (background dark)) (:foreground "LightGoldenrod"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 "Face used for level 2 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 (defface org-level-3-face ;; font-lock-keyword-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (((class color) (background light)) (:foreground "Purple"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 (((class color) (background dark)) (:foreground "Cyan"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 "Face used for level 3 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 (defface org-level-4-face ;; font-lock-comment-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 '((((type tty pc) (class color) (background light)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 (((class color) (background light)) (:foreground "Firebrick"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 (((class color) (background dark)) (:foreground "chocolate1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 "Face used for level 4 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (defface org-level-5-face ;; font-lock-type-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 (((class color) (background light)) (:foreground "ForestGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 (((class color) (background dark)) (:foreground "PaleGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 "Face used for level 5 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 (defface org-level-6-face ;; font-lock-constant-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 '((((type tty) (class color)) (:foreground "magenta"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (((class color) (background light)) (:foreground "CadetBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (((class color) (background dark)) (:foreground "Aquamarine"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 "Face used for level 6 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 (defface org-level-7-face ;; font-lock-builtin-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 '((((type tty) (class color)) (:foreground "blue" :weight light))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (((class color) (background light)) (:foreground "Orchid"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 (((class color) (background dark)) (:foreground "LightSteelBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 "Face used for level 7 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1293 (defface org-level-8-face ;; font-lock-string-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 (((class color) (background light)) (:foreground "RosyBrown"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (((class color) (background dark)) (:foreground "LightSalmon"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (t (:italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 "Face used for level 8 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 (defface org-warning-face ;; font-lock-warning-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 '((((type tty) (class color)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 (((class color) (background light)) (:foreground "Red" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 (((class color) (background dark)) (:foreground "Pink" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 "Face for deadlines and TODO keyords."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1309 (defcustom org-fontify-done-headline nil
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1310 "Non-nil means, change the face of a headline if it is marked DONE.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1311 Normally, only the TODO/DONE keyword indicates the state of a headline.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1312 When this is non-nil, the headline after the keyword is set to the
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1313 `org-headline-done-face' as an additional indication."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1314 :group 'org-faces
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1315 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1316
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1317 (defface org-headline-done-face ;; font-lock-string-face
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1318 '((((type tty) (class color)) (:foreground "green"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1319 (((class color) (background light)) (:foreground "RosyBrown"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1320 (((class color) (background dark)) (:foreground "LightSalmon"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1321 (t (:italic t)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1322 "Face used to indicate that a headline is DONE. See also the variable
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1323 `org-fontify-done-headline'."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1324 :group 'org-faces)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1325
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1326 ;; Inheritance does not yet work for xemacs. So we just copy...
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (defface org-deadline-announce-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 "Face for upcoming deadlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (defface org-scheduled-today-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 (((class color) (background light)) (:foreground "DarkGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 (((class color) (background dark)) (:foreground "PaleGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 "Face for items scheduled for a certain day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 (defface org-scheduled-previously-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 '((((type tty pc) (class color) (background light)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 (((class color) (background light)) (:foreground "Firebrick"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 (((class color) (background dark)) (:foreground "chocolate1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 "Face for items scheduled previously, and not yet done."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 (defface org-link-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 (((class color) (background light)) (:foreground "Purple"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (((class color) (background dark)) (:foreground "Cyan"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 "Face for links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 (defface org-done-face ;; font-lock-type-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 (((class color) (background dark)) (:foreground "PaleGreen" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 "Face used for DONE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (defface org-table-face ;; font-lock-function-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 "Face used for tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 (defvar org-level-faces
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 '(
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 org-level-1-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 org-level-2-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 org-level-3-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 org-level-4-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 org-level-5-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 org-level-6-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 org-level-7-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 org-level-8-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 (defvar org-n-levels (length org-level-faces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 ;; Tell the compiler about dynamically scoped variables,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 ;; and variables from other packages
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (eval-when-compile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 (defvar zmacs-regions)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1394 (defvar original-date)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 (defvar org-transient-mark-mode)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1396 (defvar org-old-auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1397 (defvar orgtbl-mode-menu)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 (defvar org-html-entities)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 (defvar org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (defvar org-cursor-color)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 (defvar org-time-was-given)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (defvar org-ts-what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 (defvar timecnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 (defvar levels-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (defvar title)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 (defvar author)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 (defvar email)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 (defvar text)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (defvar entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 (defvar date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 (defvar language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 (defvar options)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (defvar ans1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 (defvar ans2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (defvar starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (defvar include-all-loc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 (defvar vm-message-pointer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 (defvar vm-folder-directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (defvar wl-summary-buffer-elmo-folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (defvar wl-summary-buffer-folder-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (defvar gnus-group-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 (defvar gnus-article-current)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (defvar w3m-current-url)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (defvar org-selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 (defvar calendar-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (defvar remember-save-after-remembering)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 (defvar remember-data-file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 ;;; Define the mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 (defvar org-mode-map (copy-keymap outline-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 "Keymap for Org-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 (defvar org-struct-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 (defvar org-org-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 (defun org-mode (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440 "Outline-based notes management and organizer, alias
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 \"Carstens outline-mode for keeping track of everything.\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443 Org-mode develops organizational tasks around a NOTES file which
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1444 contains information about projects as plain text. Org-mode is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445 implemented on top of outline-mode, which is ideal to keep the content
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 of large files well structured. It supports ToDo items, deadlines and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 time stamps, which magically appear in the diary listing of the Emacs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 calendar. Tables are easily created with a built-in table editor.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 Plain text URL-like links connect to websites, emails (VM), Usenet
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 messages (Gnus), BBDB entries, and any files related to the project.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 For printing and sharing of notes, an Org-mode file (or a part of it)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 can be exported as a well-structured ASCII or HTML file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1454 The following commands are available:
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 \\{org-mode-map}"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 (outline-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 (setq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 (setq mode-name "Org")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (use-local-map org-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (easy-menu-add org-org-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 (setq outline-regexp "\\*+")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (if org-startup-truncated (setq truncate-lines t))
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1466 (org-set-regexps-and-options)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (set (make-local-variable 'font-lock-unfontify-region-function)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 'org-unfontify-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 ;; Activate before-change-function
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1470 (set (make-local-variable 'org-table-may-need-update) t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1471 (make-local-hook 'before-change-functions) ;; needed for XEmacs
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (add-hook 'before-change-functions 'org-before-change-function nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 'local)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (set (make-local-variable 'auto-fill-inhibit-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 (concat "\\*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (if (or org-enable-table-editor org-enable-fixed-width-editor)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 "\\|[ \t]*["
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (if org-enable-table-editor "|" "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 (if org-enable-fixed-width-editor ":" "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 "]"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 ;; Hook, and startup actions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 (if (or arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (and org-insert-mode-line-in-empty-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (= (point-min) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (insert " -*- mode: org -*-\n\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 (run-hooks 'org-mode-hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 (if org-startup-with-deadline-check
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 (call-interactively 'org-check-deadlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (if org-startup-folded (org-cycle t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 ;;; Font-Lock stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 (defvar org-mouse-map (make-sparse-keymap))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 (define-key org-mouse-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (define-key org-mouse-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 (require 'font-lock)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (defconst org-link-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 (if org-allow-space-in-links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^\t\n\r]+[^ \t\n\r]\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ \t\n\r]+\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510 "Regular expression for matching links.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 (defconst org-ts-lengths
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (cons (length (format-time-string (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (length (format-time-string (cdr org-time-stamp-formats))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 "This holds the lengths of the two different time formats.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*\\)>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 "Regular expression for fast time stamp matching.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 (defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\([^0-9>\r\n]*\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 "Regular expression matching time strings for analysis.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 ">")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 "Regular expression matching time stamps, with groups.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 "Regular expression matching a time stamp range.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 org-ts-regexp "\\)?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 "Regular expression matching a time stamp or time stamp range.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 (defun org-activate-links (limit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 "Run through the buffer and add overlays to links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 (if (re-search-forward org-link-regexp limit t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (add-text-properties (match-beginning 0) (match-end 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 (list 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 'keymap org-mouse-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 (defun org-activate-dates (limit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 "Run through the buffer and add overlays to links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 (if (re-search-forward org-tsr-regexp limit t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 (add-text-properties (match-beginning 0) (match-end 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 (list 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 'keymap org-mouse-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 (defun org-font-lock-level ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 (defun org-set-font-lock-defaults ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 (let ((org-font-lock-extra-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 '(org-activate-links (0 'org-link-face))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 '(org-activate-dates (0 'org-link-face))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 (list (concat "^\\*+[ \t]*" org-not-done-regexp) '(1 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (list (concat "\\[#[A-Z]\\]") '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (list (concat "\\<" org-deadline-string) '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 (list (concat "\\<" org-scheduled-string) '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 ;; (3 'bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 ;; (3 'italic))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 ;; (3 'underline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 '("\\<FIXME\\>" (0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 '(1 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 '("^#.*" (0 'font-lock-comment-face t))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1570 (if org-fontify-done-headline
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1571 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1572 '(1 'org-done-face t) '(2 'org-headline-done-face t))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1573 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1574 '(1 'org-done-face t)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 (1 'org-table-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 '("^[ \t]*\\(:.*\\)" (1 'org-table-face t)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 (set (make-local-variable 'org-font-lock-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 (if org-noutline-p ; FIXME: I am not sure if eval will work
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 ; on XEmacs if noutline is ever ported
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 '((eval . (list "^\\(\\*+\\).*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 0 '(nth
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 (% (- (match-end 1) (match-beginning 1) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 org-n-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 org-level-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 nil t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 '(("^\\(\\(\\*+\\)[^\r\n]*\\)[\n\r]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 (1 (nth (% (- (match-end 2) (match-beginning 2) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 org-n-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 org-level-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 nil t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 org-font-lock-extra-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 (set (make-local-variable 'font-lock-defaults)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 '(org-font-lock-keywords t nil nil backward-paragraph))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (kill-local-variable 'font-lock-keywords) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 (defvar org-font-lock-keywords nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (defun org-unfontify-region (beg end &optional maybe_loudly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 "Remove fontification and activation overlays from links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602 (font-lock-default-unfontify-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 (let* ((modified (buffer-modified-p)) ;; FIXME: Why did I add this???
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 (buffer-undo-list t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 (inhibit-read-only t) (inhibit-point-motion-hooks t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 (inhibit-modification-hooks t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 deactivate-mark buffer-file-name buffer-file-truename)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 (remove-text-properties beg end '(mouse-face nil keymap nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 ;;; Visibility cycling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 (defvar org-cycle-global-status nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (defvar org-cycle-subtree-status nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 (defun org-cycle (&optional arg)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1615 "Visibility cycling for Org-mode.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 - When this function is called with a prefix argument, rotate the entire
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 buffer through 3 states (global cycling)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 1. OVERVIEW: Show only top-level headlines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 2. CONTENTS: Show all headlines of all levels, but no body text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 3. SHOW ALL: Show everything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623 - When point is at the beginning of a headline, rotate the subtree started
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 by this line through 3 different states (local cycling)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 1. FOLDED: Only the main headline is shown.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 2. CHILDREN: The main headline and the direct children are shown. From
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 this state, you can move to one of the children and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 zoom in further.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 3. SUBTREE: Show the entire subtree, including body text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1631 - When there is a numeric prefix, go ARG levels up and do a `show-subtree',
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1632 keeping cursor position.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1633
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 - When point is not at the beginning of a headline, execute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 `indent-relative', like TAB normally does. See the option
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 `org-cycle-emulate-tab' for details.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 - Special case: if point is the the beginning of the buffer and there is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 no headline in line 1, this function will act as if called with prefix arg."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1642 (if (or (and (bobp) (not (looking-at outline-regexp)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1643 (equal arg '(4)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1644 ;; special case: use global cycling
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 (setq arg t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1648
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1649 ((org-at-table-p 'any)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1650 ;; Enter the table or move to the next field in the table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651 (or (org-table-recognize-table.el)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1652 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1653 (org-table-justify-field-maybe)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1654 (org-table-next-field))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1656 ((eq arg t) ;; Global cycling
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1658 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660 (eq org-cycle-global-status 'overview))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 ;; We just created the overview - now do table of contents
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 ;; This can be slow in very large buffers, so indicate action
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 (message "CONTENTS...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 ;; Visit all headings and show their offspring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 (while (and (progn (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (outline-previous-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 (error (goto-char (point-min))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 (show-branches)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 (if (bobp) (throw 'exit nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 (message "CONTENTS...done"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 (setq org-cycle-global-status 'contents))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1677
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (eq org-cycle-global-status 'contents))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 ;; We just showed the table of contents - now show everything
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 (show-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 (message "SHOW ALL")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 (setq org-cycle-global-status 'all))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1684
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 ;; Default action: go to overview
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687 (hide-sublevels 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 (message "OVERVIEW")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689 (setq org-cycle-global-status 'overview))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1691 ((integerp arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1692 ;; Show-subtree, ARG levels up from here.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1693 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1694 (org-back-to-heading)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1695 (outline-up-heading arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1696 (show-subtree)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1697
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 ((save-excursion (beginning-of-line 1) (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 ;; At a heading: rotate between three different views
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (let ((goal-column 0) beg eoh eol eos nxh)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702 ;; First, some boundaries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 (org-back-to-heading) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 (while (and (not (eobp)) ;; this is like `next-line'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 (get-char-property (1- (point)) 'invisible))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (beginning-of-line 2)) (setq eol (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 (outline-end-of-heading) (setq eoh (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 (outline-end-of-subtree) (setq eos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 (outline-next-heading) (setq nxh (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 ;; Find out what to do next and set `this-command'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715 ((= eos eoh)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 ;; Nothing is hidden behind this heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717 (message "EMPTY ENTRY")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1718 (setq org-cycle-subtree-status nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 ((>= eol eos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 ;; Entire subtree is hidden in one line: open it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 (show-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1722 (show-children)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 (message "CHILDREN")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 (setq org-cycle-subtree-status 'children))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1725 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 (eq org-cycle-subtree-status 'children))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727 ;; We just showed the children, now show everything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 (show-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 (message "SUBTREE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 (setq org-cycle-subtree-status 'subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 ;; Default action: hide the subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1733 (hide-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 (message "FOLDED")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735 (setq org-cycle-subtree-status 'folded)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 ;; TAB emulation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 (buffer-read-only (org-back-to-heading))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739 ((if (and (eq org-cycle-emulate-tab 'white)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 (save-excursion (beginning-of-line 1) (looking-at "[ \t]+$")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 (eq org-cycle-emulate-tab t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 (if (and (looking-at "[ \n\r\t]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 (string-match "^[ \t]*$" (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 (point-at-bol) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1747 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1748 (and (looking-at "[ \t]+") (replace-match ""))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 (indent-relative))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 (t (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 (org-cycle)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 (defvar org-goto-window-configuration nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (defvar org-goto-marker nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (defvar org-goto-map (make-sparse-keymap))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 (let ((cmds '(isearch-forward isearch-backward)) cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 (while (setq cmd (pop cmds))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760 (substitute-key-definition cmd cmd org-goto-map global-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 (define-key org-goto-map [(return)] 'org-goto-ret)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 (define-key org-goto-map [(left)] 'org-goto-left)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (define-key org-goto-map [(right)] 'org-goto-right)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (define-key org-goto-map [(?q)] 'org-goto-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 (define-key org-goto-map [(control ?g)] 'org-goto-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 (define-key org-goto-map [(tab)] 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 (define-key org-goto-map [(down)] 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 (define-key org-goto-map [(up)] 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 (define-key org-goto-map "n" 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (define-key org-goto-map "p" 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (define-key org-goto-map "f" 'outline-forward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (define-key org-goto-map "b" 'outline-backward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 (define-key org-goto-map "u" 'outline-up-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 (define-key org-goto-map "\C-c\C-n" 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 (define-key org-goto-map "\C-c\C-p" 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (define-key org-goto-map "\C-c\C-f" 'outline-forward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 (define-key org-goto-map "\C-c\C-b" 'outline-backward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 (define-key org-goto-map "\C-c\C-u" 'outline-up-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 (while l (define-key org-goto-map (int-to-string (pop l)) 'digit-argument)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 (defconst org-goto-help
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 "Select a location to jump to, press RET
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 \[Up]/[Down]=next/prev headline TAB=cycle visibility RET=select [Q]uit")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 (defun org-goto ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 "Go to a different location of the document, keeping current visibility.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 When you want to go to a different location in a document, the fastest way
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 is often to fold the entire buffer and then dive into the tree. This
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 method has the disadvantage, than the previous location will be folded, and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 that can be unwanted.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 This command works around this by showing a copy of the current buffer in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 overview mode. You can dive into the tree in that copy, to find the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 location you want to reach. When pressing RET, the command returns to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 original buffer in which the visibility is still unchanged. It then jumps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 to the new location, making it and the headline hierarchy above it visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 (let* ((org-goto-start-pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 (selected-point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 (org-get-location (current-buffer) org-goto-help)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (if selected-point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (goto-char selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (if (org-invisible-p) (org-show-hierarchy-above)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (error "Quit"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (defun org-get-location (buf help)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810 "Let the user select a location in the Org-mode buffer BUF.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 This function uses a recursive edit. It returns the selected position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 or nil."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 (let (org-selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 (switch-to-buffer (get-buffer-create "*org-goto*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 (with-output-to-temp-buffer "*Help*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 (princ help))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 (insert-buffer buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (let ((org-startup-truncated t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 (org-startup-folded t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 (org-startup-with-deadline-check nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (org-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (setq buffer-read-only t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 (if (boundp 'org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 (goto-char org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 (goto-char (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 (org-beginning-of-line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 (message "Select location and press RET")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 ;; now we make sure that during selection, ony very few keys work
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 ;; and that it is impossible to switch to another window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 (let ((gm (current-global-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (overriding-local-map org-goto-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 (use-global-map org-goto-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 (recursive-edit))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 (use-global-map gm)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (kill-buffer "*org-goto*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 org-selected-point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 ;; FIXME: It may not be a good idea to temper with the prefix argument...
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 (defun org-goto-ret (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 current-prefix-arg arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (defun org-goto-left (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 (if (org-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1860 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1861 current-prefix-arg (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1862 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1863 (error "Not on a heading")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1864
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1865 (defun org-goto-right (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1866 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1867 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 (if (org-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1869 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 (outline-end-of-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1871 (or (eobp) (forward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1872 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1873 current-prefix-arg (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1875 (error "Not on a heading")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1877 (defun org-goto-quit ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 "Finish org-goto without cursor motion."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1880 (setq org-selected-point nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 ;;; Promotion, Demotion, Inserting new headlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (defvar org-ignore-region nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1886 "To temporary disable the active region.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1888 (defun org-insert-heading (arg)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889 "Insert a new heading with same depth at point."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1890 (interactive "P")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1891 (let* ((head (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 (error (outline-next-heading)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1895 (prog1 (match-string 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 (funcall outline-level)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 (unless (bolp) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 (insert head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 (unless (eolp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 (save-excursion (newline-and-indent)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901 (unless (equal (char-before) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1902 (insert " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1903 (run-hooks 'org-insert-heading-hook)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1904
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1905 (defun org-promote-subtree (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 "Promote the entire subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 See also `org-promote'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 (org-map-tree 'org-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911 (defun org-demote-subtree (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 "Demote the entire subtree. See `org-demote'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 See also `org-promote'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 (org-map-tree 'org-demote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 (defun org-do-promote (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 "Promote the current heading higher up the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 If the region is active in transient-mark-mode, promote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 (org-map-region 'org-promote (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 (org-promote)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 (org-fix-position-after-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 (defun org-do-demote (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 "Demote the current heading lower down the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930 If the region is active in transient-mark-mode, demote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 (org-map-region 'org-demote (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 (org-demote)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 (org-fix-position-after-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 (defun org-fix-position-after-promote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 "Make sure that after pro/demotion cursor position is right."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (and (equal (char-after) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 (equal (char-before) ?*)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 (forward-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 (defun org-promote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 "Promote the current heading higher up the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 If the region is active in transient-mark-mode, promote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (let* ((level (save-match-data (funcall outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (up-head (make-string (1- level) ?*)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 (replace-match up-head nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 (org-fixup-indentation "^ " "" "^ ?\\S-"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1957 (defun org-demote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 "Demote the current heading lower down the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 If the region is active in transient-mark-mode, demote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 (let* ((level (save-match-data (funcall outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 (down-head (make-string (1+ level) ?*)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 (replace-match down-head nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (org-fixup-indentation "^ " " " "^\\S-"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968 (defun org-map-tree (fun)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 "Call FUN for every heading underneath the current one."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 (let ((level (outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1973 (funcall fun)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974 (while (and (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975 (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 (> (funcall outline-level) level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 (not (eobp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 (funcall fun)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980 (defun org-map-region (fun beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 "Call FUN for every heading between BEG and END."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1982 (let ((org-ignore-region t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 (setq end (copy-marker end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1985 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 ;; (if (fboundp 'deactivate-mark) (deactivate-mark))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 ;; (if (fboundp 'zmacs-deactivate-region) (zmacs-deactivate-region))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 (if (and (re-search-forward (concat "^" outline-regexp) nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (funcall fun))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 (while (and (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1994 (not (eobp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 (funcall fun)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1997 (defun org-fixup-indentation (from to prohibit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1998 "Change the indentation in the current entry by re-replacing FROM with TO.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 However, if the regexp PROHIBIT matches at all, don't do anything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 This is being used to change indentation along with the length of the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 heading marker. But if there are any lines which are not indented, nothing
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2002 is changed at all."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2003 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004 (let ((end (save-excursion (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 (point-marker))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 (unless (save-excursion (re-search-forward prohibit end t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 (while (re-search-forward from end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2008 (replace-match to)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009 (beginning-of-line 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010 (move-marker end nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012 ;;; Vertical tree motion, cutting and pasting of subtrees
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2013
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014 (defun org-move-subtree-up (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2015 "Move the current subtree up past ARG headlines of the same level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017 (org-move-subtree-down (- (prefix-numeric-value arg))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019 (defun org-move-subtree-down (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020 "Move the current subtree down past ARG headlines of the same level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022 (setq arg (prefix-numeric-value arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 (let ((movfunc (if (> arg 0) 'outline-get-next-sibling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024 'outline-get-last-sibling))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2025 (ins-point (make-marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 (cnt (abs arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2027 beg end txt folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 ;; Select the tree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 (save-excursion (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 (setq folded (org-invisible-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 (outline-end-of-subtree))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2035 (outline-next-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2036 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 ;; Find insertion point, with error handling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 (while (> cnt 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040 (or (and (funcall movfunc) (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 (progn (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 (error "Cannot move past superior level or buffer limit")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2043 (setq cnt (1- cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044 (if (> arg 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 ;; Moving forward - still need to move over subtree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 (progn (outline-end-of-subtree)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2047 (outline-next-heading)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2048 (if (not (or (looking-at (concat "^" outline-regexp))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2049 (bolp)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2050 (newline))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2051 (move-marker ins-point (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052 (setq txt (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 (goto-char ins-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2056 (if folded (hide-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 (move-marker ins-point nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2058
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059 (defvar org-subtree-clip ""
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 "Clipboard for cut and paste of subtrees.
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2061 This is actually only a copy of the kill, because we use the normal kill
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2062 ring. We need it to check if the kill was created by `org-copy-subtree'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2063
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2064 (defvar org-subtree-clip-folded nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2065 "Was the last copied suptree folded?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 This is used to fold the tree back after pasting.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2067
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2068 (defun org-cut-subtree (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 "Cut the current subtree into the clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 This is a short-hand for marking the subtree and then cutting it."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (org-copy-subtree arg 'cut))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2073
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2074 (defun org-copy-subtree (&optional arg cut)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 "Cut the current subtree into the clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2076 This is a short-hand for marking the subtree and then copying it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2077 If CUT is non nil, actually cur the subtree."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2078 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2079 (let (beg end folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2083 (save-excursion (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2084 (setq folded (org-invisible-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2085 (outline-end-of-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2086 (if (equal (char-after) ?\n) (forward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2087 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2088 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2089 (when (> end beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2090 (setq org-subtree-clip-folded folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 (if cut (kill-region beg end) (copy-region-as-kill beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 (setq org-subtree-clip (current-kill 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2093 (message "%s: Subtree with %d characters"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2094 (if cut "Cut" "Copied")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095 (length org-subtree-clip)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2096
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2097 (defun org-paste-subtree (&optional level tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2098 "Paste the clipboard as a subtree, with modification of headline level.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 The entire subtree is promoted or demoted in order to match a new headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 level. By default, the new level is derived from the visible headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2101 before and after the insertion point, and taken to be the inferior headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 level of the two. So if the previous visible heading is level 3 and the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2103 next is level 4 (or vice versa), level 4 will be used for insertion.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2104 This makes sure that the subtree remains an independent subtree and does
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2105 not swallow low level entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107 You can also force a different level, either by using a numeric prefix
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 argument, or by inserting the heading marker by hand. For example, if the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 cursor is after \"*****\", then the tree will be shifted to level 5.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 If you want to insert the tree as is, just use \\[yank].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2113 If optional TREE is given, use this text instead of the kill ring."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115 (unless (org-kill-is-subtree-p tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118 "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119 (let* ((txt (or tree (current-kill 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 (^re (concat "^\\(" outline-regexp "\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (re (concat "\\(" outline-regexp "\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 (^re_ (concat "\\(" outline-regexp "\\)[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 (old-level (if (string-match ^re txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127 (force-level (cond (level (prefix-numeric-value level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2128 ((string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2129 ^re_ (buffer-substring (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131 (t nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 (prevous-level (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2133 (outline-previous-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134 (if (looking-at re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2137 (next-level (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2138 (outline-next-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2139 (if (looking-at re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 (new-level (or force-level (max prevous-level next-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2143 (shift (if (or (= old-level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 (= new-level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (= old-level new-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2147 (- new-level old-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 (shift1 shift)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 (delta (if (> shift 0) -1 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (func (if (> shift 0) 'org-demote 'org-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 ;; Remove the forces level indicator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (if force-level
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (delete-region (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 ;; Make sure we start at the beginning of an empty line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 (if (not (bolp)) (insert "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2157 (if (not (looking-at "[ \t]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 (progn (insert "\n") (backward-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159 ;; Paste
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 ;; Shift if necessary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 (if (= shift 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2166 (message "Pasted at level %d, without shift" new-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2168 (narrow-to-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 (while (not (= shift 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170 (org-map-region func (point-min) (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2171 (setq shift (+ delta shift)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2172 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2173 (message "Pasted at level %d, with shift by %d levels"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174 new-level shift1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175 (if (and (eq org-subtree-clip (current-kill 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 org-subtree-clip-folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177 ;; The tree was folded before it was killed/copied
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178 (hide-subtree))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180 (defun org-kill-is-subtree-p (&optional txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181 "Check if the current kill is an outline subtree, or a set of trees.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 Returns nil if kill does not start with a headline, or if the first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 headline level is not the largest headline level in the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184 So this will actually acceept several entries of equal levels as well,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2185 which is OK for `org-paste-subtree'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2186 If optional TXT is given, check this string instead of the current kill."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187 (let* ((kill (or txt (current-kill 0) ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188 (start-level (and (string-match (concat "\\`" outline-regexp) kill)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 (re (concat "^" outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 (start 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 (if (not start-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 nil ;; does not even start with a heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 (while (setq start (string-match re kill (1+ start)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 (if (< (- (match-end 0) (match-beginning 0)) start-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 (throw 'exit nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200 ;;; Completion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202 (defun org-complete (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 "Perform completion on word at point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 At the beginning of a headline, this completes TODO keywords as given in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 `org-todo-keywords'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 If the current word is preceeded by a backslash, completes the TeX symbols
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 that are supported for HTML support.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 If the current word is preceeded by \"#+\", completes special words for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 setting file options.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 At all other locations, this simply calls `ispell-complete-word'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2212 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2213 (let* ((end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2214 (beg (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 (if (equal (char-before (point)) ?\ ) (backward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 (skip-chars-backward "a-zA-Z0-9_:")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2217 (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 (texp (equal (char-before beg) ?\\))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 "#+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 (pattern (buffer-substring-no-properties beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 (completion-ignore-case opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 (type nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225 (table (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 (opt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (setq type :opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 (mapcar (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230 (cons (match-string 2 x) (match-string 1 x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2231 (org-split-string (org-get-current-options) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2232 (texp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233 (setq type :tex)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 org-html-entities)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 ((string-match "\\`\\*+[ \t]*\\'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 (buffer-substring (point-at-bol) beg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237 (setq type :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238 (mapcar 'list org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2239 (t (progn (ispell-complete-word arg) (throw 'exit nil)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 (completion (try-completion pattern table)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241 (cond ((eq completion t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2242 (if (equal type :opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2243 (insert (substring (cdr (assoc (upcase pattern) table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 (length pattern)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 ((null completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246 (message "Can't find completion for \"%s\"" pattern)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2247 (ding))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2248 ((not (string= pattern completion))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 (if (string-match " +$" completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (setq completion (replace-match "" t t completion)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 (insert completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 (if (get-buffer-window "*Completions*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 (delete-window (get-buffer-window "*Completions*")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 (if (and (eq type :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (assoc completion table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 (insert " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 (if (and (equal type :opt) (assoc completion table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 "Press \\[org-complete] again to insert example settings"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (message "Making completion list...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 (let ((list (sort (all-completions pattern table) 'string<)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 (with-output-to-temp-buffer "*Completions*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 (display-completion-list list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (message "Making completion list...%s" "done"))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 ;;; Comments, TODO and DEADLINE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270 (defun org-toggle-comment ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 "Change the COMMENT state of an entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (if (looking-at (concat outline-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 "\\( +\\<" org-comment-string "\\>\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 (replace-match "" t t nil 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (if (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 (goto-char (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281 (insert " " org-comment-string))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 (defun org-todo (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 "Change the TODO state of an item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 The state of an item is given by a keyword at the start of the heading,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 like
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 *** TODO Write paper
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 *** DONE Call mom
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 The different keywords are specified in the variable `org-todo-keywords'. By
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 default the available states are \"TODO\" and \"DONE\".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 So for this example: when the item starts with TODO, it is changed to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 When it starts with DONE, the DONE is removed. And when neither TODO nor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 DONE are present, add TODO at the beginning of the heading.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 With prefix arg, use completion to determined the new state. With numeric
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 prefix arg, switch to that state."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 (if (looking-at outline-regexp) (goto-char (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302 (or (looking-at (concat " +" org-todo-regexp " *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 (looking-at " *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 (let* ((this (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 (completion-ignore-case t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306 (member (member this org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 (tail (cdr member))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (state (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 ((equal arg '(4))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 ;; Read a state with completion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 (completing-read "State: " (mapcar (lambda(x) (list x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 org-todo-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2313 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2314 (arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2315 ;; user requests a specific state
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 (nth (1- (prefix-numeric-value arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 ((null member) (car org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 ((null tail) nil) ;; -> first entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320 ((eq org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321 (car tail))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322 ((memq org-todo-interpretation '(type priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 (if (eq this-command last-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 (car tail)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 (if (> (length tail) 0) org-done-string nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326 (t nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2327 (next (if state (concat " " state " ") " ")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2328 (replace-match next t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 (run-hooks 'org-after-todo-state-change-hook)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 ;; Fixup cursor location if close to the keyword
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (if (and (outline-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 (not (bolp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333 (save-excursion (goto-char (point-at-bol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 (looking-at org-todo-line-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335 (< (point) (+ 2 (or (match-end 2) (match-end 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 (goto-char (or (match-end 2) (match-end 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 (just-one-space))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 (defun org-show-todo-tree (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2341 "Make a compact tree which shows all headlines marked with TODO.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 The tree will show the lines where the regexp matches, and all higher
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 headlines above the match."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 (let ((case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 (kwd-re (if arg org-todo-regexp org-not-done-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347 (message "%d TODO entries found"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348 (org-occur (concat "^" outline-regexp " +" kwd-re )))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2349
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350 (defun org-deadline ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2351 "Insert the DEADLINE: string to make a deadline.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352 A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 to modify it to the correct date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 org-deadline-string " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 (format-time-string (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358 (org-read-date nil 'to-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360 "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 (defun org-schedule ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 "Insert the SCHEDULED: string to schedule a TODO item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364 A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 to modify it to the correct date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 org-scheduled-string " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 (format-time-string (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 (org-read-date nil 'to-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 (defun org-occur (regexp &optional callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 "Make a compact tree which shows all matches of REGEXP.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377 The tree will show the lines where the regexp matches, and all higher
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 headlines above the match. It will also show the heading after the match,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 to make sure editing the matching entry is easy.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 if CALLBACK is non-nil, it is a function which is called to confirm
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2381 that the match should indeed be shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2382 (interactive "sRegexp: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 (setq regexp (org-check-occur-regexp regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 (let ((cnt 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2386 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2387 (hide-sublevels 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2389 (when (or (not callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2390 (funcall callback))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2391 (setq cnt (1+ cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2392 (org-show-hierarchy-above))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2393 (if (interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2394 (message "%d match(es) for regexp %s" cnt regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2397 (defun org-show-hierarchy-above ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2398 "Make sure point and the headings hierarchy above is visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2399 (if (org-on-heading-p t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2400 (org-flag-heading nil) ; only show the heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2401 (org-show-hidden-entry)) ; show entire entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 (save-excursion
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2403 (and org-show-following-heading
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2404 (outline-next-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2406 (save-excursion ; show all higher headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 (while (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 (progn (org-up-heading-all 1) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 (error nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 (org-flag-heading nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412 ;;; Priorities
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z]\\)\\] ?\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 "Regular expression matching the priority indicator.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (defun org-priority-up ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418 "Increase the priority of the current item."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2420 (org-priority 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2421
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2422 (defun org-priority-down ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423 "Decrease the priority of the current item."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425 (org-priority 'down))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2426
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 (defun org-priority (&optional action)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 "Change the priority of an item by ARG.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429 ACTION can be set, up, or down."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 (setq action (or action 'set))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432 (let (current new news have remove)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 (if (looking-at org-priority-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 (setq current (string-to-char (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437 have t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438 (setq current org-default-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2439 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2440 ((eq action 'set)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 (message (format "Priority A-%c, SPC to remove: " org-lowest-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 (setq new (read-char-exclusive))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 (if (equal new ?\ ) (setq remove t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 ((eq action 'up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 (setq new (1- current)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446 ((eq action 'down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2447 (setq new (1+ current)))
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59596
diff changeset
2448 (t (error "Invalid action")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 (setq new (min (max ?A (upcase new)) org-lowest-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 (setq news (format "%c" new))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2451 (if have
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452 (if remove
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 (replace-match "" t t nil 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2454 (replace-match news t t nil 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2455 (looking-at org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2456 (if (match-end 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458 (goto-char (match-end 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (insert " [#" news "]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 (goto-char (match-beginning 3))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 (insert "[#" news "] "))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 (if remove
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 (message "Priority removed")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 (message "Priority of current item set to %s" news))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 (defun org-get-priority (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 "Find priority cookie and return priority."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2470 (if (not (string-match org-priority-regexp s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 (* 1000 (- org-lowest-priority org-default-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 (* 1000 (- org-lowest-priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 (string-to-char (match-string 2 s)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 ;;; Timestamps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2477 (defvar org-last-changed-timestamp nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 (defun org-time-stamp (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 "Prompt for a date/time and insert a time stamp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 If the user specifies a time like HH:MM, or if this command is called
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 with a prefix argument, the time stamp will contain date and time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 Otherwise, only the date will be included. All parts of a date not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 specified by the user will be filled in from the current date/time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485 So if you press just return without typing anything, the time stamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 will represent the current date/time. If there is already a timestamp
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2487 at the cursor, it will be modified."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 (let ((fmt (if arg (cdr org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 (org-time-was-given nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 ((and (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 (eq last-command 'org-time-stamp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 (eq this-command 'org-time-stamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 (insert "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (insert (format-time-string fmt time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 ((org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2503 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 (and (org-at-timestamp-p) (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (setq org-last-changed-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (format-time-string fmt time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 (message "Timestamp updated"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 (insert (format-time-string fmt time))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516 ;;; FIXME: Make the function take "Fri" as "next friday"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 (defun org-read-date (&optional with-time to-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 "Read a date and make things smooth for the user.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2519 The prompt will suggest to enter an ISO date, but you can also enter anything
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 which will at least partially be understood by `parse-time-string'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521 Unrecognized parts of the date will default to the current day, month ,year,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2522 hour and minute. For example,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523 3-2-5 --> 2003-02-05
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 feb 15 --> currentyear-02-15
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 sep 12 9 --> 2009-09-12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 12:45 --> today 12:45
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 22 sept 0:34 --> currentyear-09-22 0:34
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 12 --> currentyear-currentmonth-12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2529 etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 The function understands only English month and weekday abbreviations,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 but this can be configured with the variables `parse-time-months' and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 `parse-time-weekdays'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2534 While prompting, a calendar is popped up - you can also select the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 date with the mouse (button 1). The calendar shows a period of three
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2536 month. To scroll it to other months, use the keys `>' and `<'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 If you don't like the calendar, turn it off with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2538 \(setq org-popup-calendar-for-date-prompt nil).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 With optional argument TO-TIME, the date will immediately be converted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2541 to an internal time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2542 With an optional argument WITH-TIME, the prompt will suggest to also
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 insert a time. Note that when WITH-TIME is not set, you can still
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 enter a time, and this function will inform the calling routine about
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 this change. The calling routine may then choose to change the format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 used to insert the time stamp into the buffer to include the time."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547 (let* ((default-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 ;; Default time is either today, or, when entering a range,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 ;; the range start.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (concat org-ts-regexp "--\\=")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 (- (point) 20) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 (apply
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2555 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2556 (mapcar (lambda(x) (or x 0)) ;; FIXME: Problem with timezone?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 (parse-time-string (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559 (timestr (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2560 (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") default-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 (prompt (format "YYYY-MM-DD [%s]: " timestr))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 ans ans1 ans2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 second minute hour day month year tl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 (if org-popup-calendar-for-date-prompt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 ;; Also show a calendar for date selection
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 ;; Copied (with modifications) from planner.el by John Wiegley
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2568 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2571 (calendar-forward-day (- (time-to-days default-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2572 (calendar-absolute-from-gregorian
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573 (calendar-current-date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 (let* ((old-map (current-local-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 (map (copy-keymap calendar-mode-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576 (minibuffer-local-map (copy-keymap minibuffer-local-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2577 (define-key map (kbd "RET") 'org-calendar-select)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 (define-key map (if org-xemacs-p [button1] [mouse-1])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 'org-calendar-select)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 (define-key minibuffer-local-map [(meta shift left)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 (org-eval-in-calendar '(calendar-backward-month 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 (define-key minibuffer-local-map [(meta shift right)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585 (org-eval-in-calendar '(calendar-forward-month 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (define-key minibuffer-local-map [(shift up)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 (org-eval-in-calendar '(calendar-backward-week 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 (define-key minibuffer-local-map [(shift down)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2590 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 (org-eval-in-calendar '(calendar-forward-week 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592 (define-key minibuffer-local-map [(shift left)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 (org-eval-in-calendar '(calendar-backward-day 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 (define-key minibuffer-local-map [(shift right)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597 (org-eval-in-calendar '(calendar-forward-day 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 (define-key minibuffer-local-map ">"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600 (org-eval-in-calendar '(scroll-calendar-left 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 (define-key minibuffer-local-map "<"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2602 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2603 (org-eval-in-calendar '(scroll-calendar-right 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 (use-local-map map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 (setq ans (read-string prompt "" nil nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 (setq ans (or ans1 ans2 ans)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 (use-local-map old-map)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 ;; Naked prompt only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 (setq ans (read-string prompt "" nil timestr)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 (if (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 "^ *\\(\\([0-9]+\\)-\\)?\\([0-1]?[0-9]\\)-\\([0-3]?[0-9]\\)\\([^-0-9]\\|$\\)" ans)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 (setq year (if (match-end 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 (string-to-number (match-string 2 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 (string-to-number (format-time-string "%Y")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 month (string-to-number (match-string 3 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620 day (string-to-number (match-string 4 ans)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621 (if (< year 100) (setq year (+ 2000 year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 (setq ans (replace-match (format "%04d-%02d-%02d" year month day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 t t ans))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 (setq tl (parse-time-string ans)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2625 year (or (nth 5 tl) (string-to-number (format-time-string "%Y")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2626 month (or (nth 4 tl) (string-to-number (format-time-string "%m")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 day (or (nth 3 tl) (string-to-number (format-time-string "%d")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2628 hour (or (nth 2 tl) (string-to-number (format-time-string "%H")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 minute (or (nth 1 tl) (string-to-number (format-time-string "%M")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 second (or (nth 0 tl) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2631 (if (and (boundp 'org-time-was-given)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 (nth 2 tl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (setq org-time-was-given t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 (if (< year 100) (setq year (+ 2000 year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2635 (if to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 (encode-time second minute hour day month year)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 (if (or (nth 1 tl) (nth 2 tl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (format "%04d-%02d-%02d %02d:%02d" year month day hour minute)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 (format "%04d-%02d-%02d" year month day)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 (defun org-eval-in-calendar (form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 "Eval FORM in the calendar window and return to current window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 Also, store the cursor date in variable ans2."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 (let ((sw (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645 (select-window (get-buffer-window "*Calendar*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 (eval form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 (when (calendar-cursor-to-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648 (let* ((date (calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (setq ans2 (format-time-string "%Y-%m-%d" time))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (select-window sw)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (defun org-calendar-select ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 "Return to `org-read-date' with the date currently selected.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2655 This is used by `org-read-date' in a temporary keymap for the calendar buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (when (calendar-cursor-to-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 (let* ((date (calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 (setq ans1 (format-time-string "%Y-%m-%d" time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 (if (active-minibuffer-window) (exit-minibuffer))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (defun org-check-deadlines (ndays)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2664 "Check if there are any deadlines due or past due.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2665 A deadline is considered due if it happens within `org-deadline-warning-days'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2666 days from todays date. If the deadline appears in an entry marked DONE,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2667 it is not shown. The prefix arg NDAYS can be used to test that many
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2668 days. If the prefix are is a raw C-u prefix, all deadlines are shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 (let* ((org-warn-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2672 ((equal ndays '(4)) 100000)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2673 (ndays (prefix-numeric-value ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674 (t org-deadline-warning-days)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 (case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2676 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 (callback
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 (lambda ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 (and (let ((d1 (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 (d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681 (org-time-string-to-time (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2682 (< (- d2 d1) org-warn-days))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2683 (not (org-entry-is-done-p))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2684 (message "%d deadlines past-due or due within %d days"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2685 (org-occur regexp callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2686 org-warn-days)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2687
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2688 (defun org-evaluate-time-range (&optional to-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2689 "Evaluate a time range by computing the difference between start and end.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2690 Normally the result is just printed in the echo area, but with prefix arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2691 TO-BUFFER, the result is inserted just after the date stamp into the buffer.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 If the time range is actually in a table, the result is inserted into the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693 next column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2694 For time difference computation, a year is assumed to be exactly 365
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695 days in order to avoid rounding problems."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2696 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 (unless (org-at-date-range-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699 (goto-char (point-at-bol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700 (re-search-forward org-tr-regexp (point-at-eol) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701 (if (not (org-at-date-range-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 (error "Not at a time-stamp range, and none found in current line.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2703 (let* ((ts1 (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 (ts2 (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 (match-end (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 (time1 (org-time-string-to-time ts1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2707 (time2 (org-time-string-to-time ts2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2708 (t1 (time-to-seconds time1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2709 (t2 (time-to-seconds time2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2710 (diff (abs (- t2 t1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 (negative (< (- t2 t1) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2712 (ys (floor (* 365 24 60 60)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2713 (ds (* 24 60 60))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2714 (hs (* 60 60))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2715 (fy "%dy %dd %02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2716 (fd "%dd %02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2717 (fh "%02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2718 y d h m align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2719 (setq y (floor (/ diff ys)) diff (mod diff ys)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2720 d (floor (/ diff ds)) diff (mod diff ds)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2721 h (floor (/ diff hs)) diff (mod diff hs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722 m (floor (/ diff 60)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 (if to-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2724 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2725 (goto-char match-end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2726 (when (and (org-at-table-p) (looking-at " *|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2727 (setq align t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2728 (goto-char (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2729 (if (looking-at
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2730 "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2731 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2732 (if negative (insert " -"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2733 (if (> y 0) (insert " " (format fy y d h m))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2734 (if (> d 0) (insert " " (format fd d h m))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 (insert " " (format fh h m))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 (if align (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2737 (message "Time difference inserted"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2738 (message (org-make-tdiff-string y d h m)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2739
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2740 (defun org-make-tdiff-string (y d h m)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2741 (let ((fmt "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2742 (l nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2743 (if (> y 0) (setq fmt (concat fmt "%d year" (if (> y 1) "s" "") " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2744 l (push y l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2745 (if (> d 0) (setq fmt (concat fmt "%d day" (if (> d 1) "s" "") " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2746 l (push d l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2747 (if (> h 0) (setq fmt (concat fmt "%d hour" (if (> h 1) "s" "") " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2748 l (push h l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2749 (if (> m 0) (setq fmt (concat fmt "%d minute" (if (> m 1) "s" "") " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2750 l (push m l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2751 (apply 'format fmt (nreverse l))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2752
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753 (defun org-time-string-to-time (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754 (apply 'encode-time (org-parse-time-string s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2755
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 (defun org-parse-time-string (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2757 "Parse the standard Org-mode time string.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 This should be a lot faster than the normal parse-time-string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2759 (if (string-match org-ts-regexp1 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 (list 0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2761 (string-to-number (or (match-string 8 s) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2762 (string-to-number (or (match-string 7 s) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2763 (string-to-number (match-string 4 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2764 (string-to-number (match-string 3 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2765 (string-to-number (match-string 2 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 nil nil nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767 (make-list 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2768
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 (defun org-timestamp-up (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770 "Increase the date item at the cursor by one.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 If the cursor is on the year, change the year. If it is on the month or
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2772 the day, change that.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2773 With prefix ARG, change by that many units."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2774 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775 (org-timestamp-change (prefix-numeric-value arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2776
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2777 (defun org-timestamp-down (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778 "Decrease the date item at the cursor by one.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779 If the cursor is on the year, change the year. If it is on the month or
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 the day, change that.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 With prefix ARG, change by that many units."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783 (org-timestamp-change (- (prefix-numeric-value arg))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 (defun org-timestamp-up-day (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2786 "Increase the date in the time stamp by one day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2787 With prefix ARG, change that many days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (org-timestamp-change (prefix-numeric-value arg) 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791 (defun org-timestamp-down-day (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 "Increase the date in the time stamp by one day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 With prefix ARG, change that many days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2794 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2795 (org-timestamp-change (- (prefix-numeric-value arg)) 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2796
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797 (defsubst org-pos-in-match-range (pos n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2798 (and (match-beginning n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2799 (<= (match-beginning n) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2800 (>= (match-end n) pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2801
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 (defun org-at-timestamp-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2803 "Determine if the the cursor is in or at a timestamp."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2804 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805 (let* ((tsr org-ts-regexp2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2807 (ans (or (looking-at tsr)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2808 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809 (skip-chars-backward "^<\n\r\t")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2810 (if (> (point) 1) (backward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2811 (and (looking-at tsr)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2812 (> (- (match-end 0) pos) -1))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2813 (and (boundp 'org-ts-what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2814 (setq org-ts-what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2815 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2816 ((org-pos-in-match-range pos 2) 'year)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2817 ((org-pos-in-match-range pos 3) 'month)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2818 ((org-pos-in-match-range pos 7) 'hour)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2819 ((org-pos-in-match-range pos 8) 'minute)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2820 ((or (org-pos-in-match-range pos 4)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2821 (org-pos-in-match-range pos 5)) 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 (t 'day))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2823 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2824
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2825 (defun org-timestamp-change (n &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2826 "Change the date in the time stamp at point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2827 The date will be changed by N times WHAT. WHAT can be `day', `month',
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2828 `year', `minute', `second'. If WHAT is not given, the cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2829 in the timestamp determines what will be changed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2830 (let ((fmt (car org-time-stamp-formats))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831 org-ts-what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2832 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2833 ts time time0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2834 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2835 (error "Not at a timestamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836 (setq org-ts-what (or what org-ts-what))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837 (setq fmt (if (<= (abs (- (cdr org-ts-lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840 (cdr org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2841 (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 (setq ts (match-string 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843 (replace-match "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 (setq time0 (org-parse-time-string ts))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (setq time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 (apply 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 (list (or (car time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2849 (list (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2850 (list (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2851 (list (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852 (list (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853 (list (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2854 (nthcdr 6 time0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 (if (eq what 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 (let ((cal-date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 (set-buffer "*Calendar*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860 (calendar-cursor-to-date)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 (setcar time0 (or (car time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 (setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 (setcar (nthcdr 2 time0) (or (nth 1 time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 (setq time (apply 'encode-time time0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 (insert (setq org-last-changed-timestamp (format-time-string fmt time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 ;; Try to recenter the calendar window, if any
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2871 (if (and org-calendar-follow-timestamp-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872 (get-buffer-window "*Calendar*" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 (memq org-ts-what '(day month year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 (org-recenter-calendar (time-to-days time)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2875
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2876 (defun org-recenter-calendar (date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2877 "If the calendar is visible, recenter it to DATE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2878 (let* ((win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 (cwin (get-buffer-window "*Calendar*" t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 (when cwin
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 (select-window cwin)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 (calendar-goto-date (if (listp date) date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 (calendar-gregorian-from-absolute date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 (select-window win))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 (defun org-goto-calendar (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 "Go to the Emacs calendar at the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 If there is a time stamp in the current line, go to that date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 A prefix ARG can be used force the current date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 (let ((tsr org-ts-regexp) diff)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 (if (or (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2894 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2895 (looking-at (concat ".*" tsr))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 (let ((d1 (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897 (d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 (org-time-string-to-time (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2899 (setq diff (- d2 d1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900 (calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2901 (calendar-goto-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (if (and diff (not arg)) (calendar-forward-day diff))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 (defun org-date-from-calendar ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 "Insert time stamp corresponding to cursor date in *Calendar* buffer.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 If there is already a time stamp at the cursor position, update it."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908 (org-timestamp-change 0 'calendar))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 ;;; Agenda, and Diary Integration
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2911
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912 ;;; Define the mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914 (defvar org-agenda-mode-map (make-sparse-keymap)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915 "Keymap for org-agenda-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 (defvar org-agenda-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2918 (defvar org-agenda-follow-mode nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919 (defvar org-agenda-buffer-name "*Org Agenda*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 (defvar org-agenda-redo-command nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2922 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 (defun org-agenda-mode ()
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2924 "Mode for time-sorted view on action items in Org-mode files.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2925
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2926 The following commands are available:
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2927
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2928 \\{org-agenda-mode-map}"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 (kill-all-local-variables)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 (setq major-mode 'org-agenda-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (setq mode-name "Org-Agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933 (use-local-map org-agenda-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 (easy-menu-add org-agenda-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 (if org-startup-truncated (setq truncate-lines t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 (setq org-agenda-follow-mode nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2938 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2939 '("Agenda") "Agenda Files"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2940 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2941 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942 ["Edit file list" (customize-variable 'org-agenda-files) t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2943 "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 (mapcar 'org-file-menu-entry org-agenda-files)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 (run-hooks 'org-agenda-mode-hook))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948 (define-key org-agenda-mode-map [(tab)] 'org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 (define-key org-agenda-mode-map [(return)] 'org-agenda-switch-to)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 (define-key org-agenda-mode-map " " 'org-agenda-show)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 (define-key org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 (define-key org-agenda-mode-map "o" 'delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 (define-key org-agenda-mode-map "l" 'org-agenda-recenter)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 (define-key org-agenda-mode-map "t" 'org-agenda-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 (define-key org-agenda-mode-map "." 'org-agenda-goto-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 (define-key org-agenda-mode-map "w" 'org-agenda-week-view)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957 (define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 (define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (define-key org-agenda-mode-map ">" 'org-agenda-date-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 (while l (define-key org-agenda-mode-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 (int-to-string (pop l)) 'digit-argument)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2965 (define-key org-agenda-mode-map "f" 'org-agenda-follow-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966 (define-key org-agenda-mode-map "d" 'org-agenda-toggle-diary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2967 (define-key org-agenda-mode-map "r" 'org-agenda-redo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2968 (define-key org-agenda-mode-map "q" 'org-agenda-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (define-key org-agenda-mode-map "x" 'org-agenda-exit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970 (define-key org-agenda-mode-map "P" 'org-agenda-show-priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 (define-key org-agenda-mode-map "p" 'org-agenda-priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 (define-key org-agenda-mode-map "," 'org-agenda-priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (define-key org-agenda-mode-map "i" 'org-agenda-diary-entry)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2974 (define-key org-agenda-mode-map "c" 'org-agenda-goto-calendar)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2975 (define-key org-agenda-mode-map "C" 'org-agenda-convert-date)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2976 (define-key org-agenda-mode-map "m" 'org-agenda-phases-of-moon)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2977 (define-key org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2978 (define-key org-agenda-mode-map "s" 'org-agenda-sunrise-sunset)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2979 (define-key org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2980 (define-key org-agenda-mode-map "h" 'org-agenda-holidays)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2981 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2983 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 (define-key org-agenda-mode-map [(right)] 'org-agenda-later)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2986
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2987 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2988 "Local keymap for agenda entries from Org-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2989
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2990 (define-key org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2991 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 (define-key org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2993 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2994
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2995 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2996 '("Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997 ("Agenda Files")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2998 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999 ["Show" org-agenda-show t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3000 ["Go To (other window)" org-agenda-goto t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3001 ["Go To (one window)" org-agenda-switch-to t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3002 ["Follow Mode" org-agenda-follow-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3003 :style toggle :selected org-agenda-follow-mode :active t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3005 ["Cycle TODO" org-agenda-todo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3006 ("Reschedule"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3007 ["Reschedule +1 day" org-agenda-date-later t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3008 ["Reschedule -1 day" org-agenda-date-earlier t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3009 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3010 ["Reschedule to today" org-agenda-date-today t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3011 ("Priority"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3012 ["Set Priority" org-agenda-priority t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3013 ["Increase Priority" org-agenda-priority-up t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 ["Decrease Priority" org-agenda-priority-down t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3015 ["Show Priority" org-agenda-show-priority t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017 ["Rebuild" org-agenda-redo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3018 ["Goto Today" org-agenda-goto-today t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3019 ["Next Dates" org-agenda-later (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020 ["Previous Dates" org-agenda-earlier (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 ["Week/Day View" org-agenda-week-view (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3023 ["Include Diary" org-agenda-toggle-diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3024 :style toggle :selected org-agenda-include-diary :active t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 ["New Diary Entry" org-agenda-diary-entry t]
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3027 ("Calendar commands"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3028 ["Goto calendar" org-agenda-goto-calendar t]
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3029 ["Phases of the Moon" org-agenda-phases-of-moon t]
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3030 ["Sunrise/Sunset" org-agenda-sunrise-sunset t]
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3031 ["Holidays" org-agenda-holidays t]
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3032 ["Convert" org-agenda-convert-date t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3033 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3034 ["Quit" org-agenda-quit t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3035 ["Exit and Release Buffers" org-agenda-exit t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3036 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3037
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3038 (defvar org-agenda-markers nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3039 "List of all currently active markers created by org-agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3040 (defvar org-agenda-last-marker-time (time-to-seconds (current-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3041 "Creation time of the last agenda marker.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3042
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3043 (defun org-agenda-new-marker (pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3044 "Return a new agenda marker.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3045 Org-mode keeps a list of these markers and resets them when they are
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3046 no longer in use."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3047 (let ((m (copy-marker pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3048 (setq org-agenda-last-marker-time (time-to-seconds (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3049 (push m org-agenda-markers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3050 m))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3051
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3052 (defun org-agenda-maybe-reset-markers (&optional force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3053 "Reset markers created by org-agenda. But only if they are old enough."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3054 (if (or force
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3055 (> (- (time-to-seconds (current-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056 org-agenda-last-marker-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 5))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 (while org-agenda-markers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (move-marker (pop org-agenda-markers) nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 (defvar org-agenda-new-buffers nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 "Buffers created to visit agenda files.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3063
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 (defun org-get-agenda-file-buffer (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3065 "Get a buffer visiting FILE. If the buffer needs to be created, add
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3066 it to the list of buffers which might be released later."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3067 (let ((buf (find-buffer-visiting file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3068 (if buf
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 buf ; just return it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3070 ;; Make a new buffer and remember it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3071 (setq buf (find-file-noselect file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3072 (if buf (push buf org-agenda-new-buffers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3073 buf)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3074
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3075 (defun org-release-buffers (blist)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3076 "Release all buffers in list, asking the user for confirmation when needed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3077 When a buffer is unmodified, it is just killed. When modified, it is saved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3078 \(if the user agrees) and then killed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3079 (let (buf file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3080 (while (setq buf (pop blist))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3081 (setq file (buffer-file-name buf))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (when (and (buffer-modified-p buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3083 file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3084 (y-or-n-p (format "Save file %s? " file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3085 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086 (set-buffer buf) (save-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3087 (kill-buffer buf))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3088
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3089 (defun org-timeline (&optional include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3090 "Show a time-sorted view of the entries in the current org file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 Only entries with a time stamp of today or later will be listed. With
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3092 one C-u prefix argument, also past entries will be listed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 With two C-u prefixes, all unfinished TODO items will also be shown,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 under the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095 If the buffer contains an active region, only check the region for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 dates."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099 (org-agenda-maybe-reset-markers 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100 (let* ((dopast include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 (dotodo (equal include-all '(16)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3102 (entry (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103 (org-agenda-files (list (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 (date (calendar-current-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3105 (win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3106 (pos1 (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 (beg (if (org-region-active-p) (region-beginning) (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 (end (if (org-region-active-p) (region-end) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 (day-numbers (org-get-all-dates beg end 'no-ranges
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3110 t)) ; always include today
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3111 (today (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112 (org-respect-restriction t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3113 (past t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 s e rtn d pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3115 (setq org-agenda-redo-command
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3116 (list 'progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 (list 'switch-to-buffer-other-window (current-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3118 (list 'org-timeline include-all)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3119 (if (not dopast)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 ;; Remove past dates from the list of dates.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3121 (setq day-numbers (delq nil (mapcar (lambda(x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3122 (if (>= x today) x nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3123 day-numbers))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3124 (switch-to-buffer-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125 (get-buffer-create org-agenda-buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3127 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 (org-agenda-mode) (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3129 (while (setq d (pop day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3130 (if (and (>= d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3131 dopast
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3132 past)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3133 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3134 (setq past nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135 (insert (make-string 79 ?-) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136 (setq date (calendar-gregorian-from-absolute d))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 (setq s (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3138 (if dotodo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3139 (setq rtn (org-agenda-get-day-entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3140 entry date :todo :timestamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3141 (setq rtn (org-agenda-get-day-entries entry date :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3142 (if (or rtn (equal d today))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144 (insert (calendar-day-name date) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3145 (number-to-string (extract-calendar-day date)) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146 (calendar-month-name (extract-calendar-month date)) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 (number-to-string (extract-calendar-year date)) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3148 (put-text-property s (1- (point)) 'face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 'org-link-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150 (if (equal d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 (put-text-property s (1- (point)) 'org-today t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3152 (insert (org-finalize-agenda-entries rtn) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3153 (put-text-property s (1- (point)) 'day d))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3154 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3155 (setq buffer-read-only t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3156 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3157 (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3158 (when (not org-select-timeline-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3159 (select-window win)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3160 (goto-char pos1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3161
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3162 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3163 (defun org-agenda (&optional include-all start-day ndays)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3164 "Produce a weekly view from all files in variable `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3165 The view will be for the current week, but from the overview buffer you
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3166 will be able to go to other weeks.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 With one C-u prefix argument INCLUDE-ALL, all unfinished TODO items will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3168 also be shown, under the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 START-DAY defaults to TODAY, or to the most recent match for the weekday
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170 given in `org-agenda-start-on-weekday'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 NDAYS defaults to `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 (org-agenda-maybe-reset-markers 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3175 (let* ((org-agenda-start-on-weekday
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3176 (if (or (equal ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3177 (and (null ndays) (equal 1 org-agenda-ndays)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 nil org-agenda-start-on-weekday))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179 (files (copy-sequence org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3180 (win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3181 (today (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 (sd (or start-day today))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 (start (if (or (null org-agenda-start-on-weekday)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3184 (< org-agenda-ndays 7))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3185 sd
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3186 (let* ((nt (calendar-day-of-week
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3187 (calendar-gregorian-from-absolute sd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3188 (n1 org-agenda-start-on-weekday)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189 (d (- nt n1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3190 (- sd (+ (if (< d 0) 7 0) d)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3191 (day-numbers (list start))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3192 s e rtn rtnall file date d start-pos end-pos)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 (setq org-agenda-redo-command
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3194 (list 'org-agenda include-all start-day ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 ;; Make the list of days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 (setq ndays (or ndays org-agenda-ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (while (> ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 (push (1+ (car day-numbers)) day-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 (setq ndays (1- ndays)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 (setq day-numbers (nreverse day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 (if (not (equal (current-buffer) (get-buffer org-agenda-buffer-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 (switch-to-buffer-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (get-buffer-create org-agenda-buffer-name))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (org-agenda-mode) (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3209 (set (make-local-variable 'starting-day) (car day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3210 (set (make-local-variable 'include-all-loc) include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211 (when (and (or include-all org-agenda-include-all-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 (member today day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3213 (setq files org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 rtnall nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3216 (catch 'nextfile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217 (org-check-agenda-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3218 (setq date (calendar-gregorian-from-absolute today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 rtn (org-agenda-get-day-entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3220 file date :todo))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222 (if rtnall (insert (org-finalize-agenda-entries rtnall) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223 (while (setq d (pop day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 (setq date (calendar-gregorian-from-absolute d)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 s (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226 (if (or (= d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227 (and (not start-pos) (= d sd)))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3228 (setq start-pos (point))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3229 (if (and start-pos (not end-pos))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3230 (setq end-pos (point))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3231 (setq files org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3232 rtnall nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 (catch 'nextfile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 (org-check-agenda-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 (setq rtn (org-agenda-get-day-entries file date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 (if org-agenda-include-diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241 (require 'diary-lib)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242 (setq rtn (org-get-entries-from-diary date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 (if (or rtnall org-agenda-show-all-dates)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246 (insert (format "%-9s %2d %-9s %4d\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (calendar-day-name date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 (extract-calendar-day date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 (calendar-month-name (extract-calendar-month date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (extract-calendar-year date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251 (put-text-property s (1- (point)) 'face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3252 'org-link-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3253 (if rtnall (insert (org-finalize-agenda-entries rtnall) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3254 (put-text-property s (1- (point)) 'day d))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 (setq buffer-read-only t)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3257 (if org-fit-agenda-window
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3258 (fit-window-to-buffer nil (/ (* (frame-height) 3) 4)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3259 (/ (frame-height) 2)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3260 (unless (and (pos-visible-in-window-p (point-min))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3261 (pos-visible-in-window-p (point-max)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3262 (goto-char (1- (point-max)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3263 (recenter -1)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3264 (if (not (pos-visible-in-window-p (or start-pos 1)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3265 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3266 (goto-char (or start-pos 1))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3267 (recenter 1))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3268 (goto-char (or start-pos 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 (if (not org-select-agenda-window) (select-window win))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 (message "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3271
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3272 (defun org-check-agenda-file (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 "Make sure FILE exists. If not, ask user what to do."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274 ;; FIXME: this does not correctly change the menus
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
3275 ;; Could probably be fixed by explicitly going to the buffer.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 (when (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 (message "non-existent file %s. [R]emove from agenda-files or [A]bort?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3278 file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279 (let ((r (downcase (read-char-exclusive))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3281 ((equal r ?r)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 (org-remove-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283 (throw 'nextfile t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3284 (t (error "Abort"))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3285
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3286 (defun org-agenda-quit (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3287 "Exit agenda by removing the window or the buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3288 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3289 (let ((buf (current-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3290 (if (not (one-window-p)) (delete-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3291 (kill-buffer buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3292 (org-agenda-maybe-reset-markers 'force)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3293
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3294 (defun org-agenda-exit (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3295 "Exit agenda by removing the window or the buffer.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3296 Also kill all Org-mode buffers which have be loaded by `org-agenda'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3297 Org-mode buffers visitied directly by the user will no be touched."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3298 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3299 (org-release-buffers org-agenda-new-buffers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3300 (setq org-agenda-new-buffers nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3301 (org-agenda-quit arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (defun org-agenda-redo (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 "Rebuild Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 (eval org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3308 (defun org-agenda-goto-today (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309 "Go to today."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 (if (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 (let ((cmd (car org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313 (iall (nth 1 org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314 (nday (nth 3 org-agenda-redo-command)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 (eval (list cmd iall nil nday)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3316 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3317 (point-min)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3319 (defun org-agenda-later (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3320 "Go forward in time by `org-agenda-ndays' days.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3321 With prefix ARG, go forward that many times `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3322 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3323 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3324 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3325 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 (+ starting-day (* arg org-agenda-ndays))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3327
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328 (defun org-agenda-earlier (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329 "Go back in time by `org-agenda-ndays' days.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3330 With prefix ARG, go back that many times `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3334 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3335 (- starting-day (* arg org-agenda-ndays))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3337 (defun org-agenda-day-view (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3338 "Switch agenda to single day view."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3340 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342 (setq org-agenda-ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343 (org-agenda include-all-loc starting-day 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345 (defun org-agenda-week-view (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3346 "Switch agenda to week view."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3347 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350 (setq org-agenda-ndays
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (if (equal org-agenda-ndays 1) 7 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3352 (org-agenda include-all-loc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 (or (get-text-property (point) 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 starting-day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 (message "Switched to %s view"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 (if (equal org-agenda-ndays 1) "day" "week")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3358
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359 (defun org-agenda-follow-mode ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 "Toggle follow mode in an agenda buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3361 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3362 (setq org-agenda-follow-mode (not org-agenda-follow-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3363 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3364 (message "Follow mode is %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 (if org-agenda-follow-mode "on" "off")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367 (defun org-agenda-toggle-diary ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 "Toggle follow mode in an agenda buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3369 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3370 (setq org-agenda-include-diary (not org-agenda-include-diary))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3371 (org-agenda-redo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (message "Diary inclusion turned %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374 (if org-agenda-include-diary "on" "off")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3376 (defun org-agenda-set-mode-name ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3377 "Set the mode name to indicate all the small mode seetings."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3378 (setq mode-name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379 (concat "Org-Agenda"
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3380 (if (equal org-agenda-ndays 1) " Day" "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3381 (if (equal org-agenda-ndays 7) " Week" "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3382 (if org-agenda-follow-mode " Follow" "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3383 (if org-agenda-include-diary " Diary" "")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3384 (force-mode-line-update))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3385
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386 (defun org-agenda-post-command-hook ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3387 (if (and org-agenda-follow-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388 (get-text-property (point) 'org-marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3389 (org-agenda-show)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391 (defun org-get-entries-from-diary (date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3392 "Get the (emacs calendar) diary entries for DATE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*")
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3394 (diary-display-hook '(fancy-diary-display))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3395 (list-diary-entries-hook
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3396 (cons 'org-diary-default-entry list-diary-entries-hook))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3397 entries
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3398 (disable-org-diary t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3400 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 (list-diary-entries date 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402 (if (not (get-buffer fancy-diary-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (setq entries nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3404 (save-excursion
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3405 (switch-to-buffer fancy-diary-buffer)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407 (if (= (point-max) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3408 ;; No entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409 (setq entries nil)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3410 ;; Omit the date and other unnecessary stuff
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3411 (org-agenda-cleanup-fancy-diary)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3412 ;; Add prefix to each line and extend the text properties
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3413 (goto-char (point-min))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3414 (while (and (re-search-forward "^" nil t) (not (eobp)))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3415 (replace-match " Diary: ")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3416 (add-text-properties (point-at-bol) (point)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3417 (text-properties-at (point))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3418 (if (= (point-max) 1)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3419 (setq entries nil)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3420 (setq entries (buffer-substring (point-min) (- (point-max) 1)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3421 (set-buffer-modified-p nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3422 (kill-buffer fancy-diary-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3423 (when entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3424 (setq entries (org-split-string entries "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 (setq entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3426 (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3427 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3428 (if (string-match "\\<\\([012][0-9]\\):\\([0-6][0-9]\\)" x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 1 (length x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431 (list 'time-of-day
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432 (+ (* 100 (string-to-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (match-string 1 x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 (string-to-number (match-string 2 x))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3437 entries)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3438
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3439 (defun org-agenda-cleanup-fancy-diary ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3440 "Remove unwanted stuff in buffer created by fancy-diary-display.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3441 This gets rid of the date, the underline under the date, and
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3442 the dummy entry installed by org-mode to ensure non-empty diary for each
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3443 date."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3444 (goto-char (point-min))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3445 (if (looking-at ".*?:[ \t]*")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3446 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3447 (replace-match "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3448 (re-search-forward "\n=+$" nil t)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3449 (replace-match "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3450 (while (re-search-backward "^ +" nil t) (replace-match "")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3451 (re-search-forward "\n=+$" nil t)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3452 (delete-region (point-min) (min (point-max) (1+ (match-end 0)))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3453 (if (re-search-forward "^Org-mode dummy\n?" nil t)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3454 (replace-match "")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3455
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3456 ;; Advise the add-to-diary-list function to allow org to jump to
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3457 ;; diary entires. Wrapped into eval-after-load to avoid loading
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3458 ;; advice unnecessarily
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3459 (eval-after-load "diary-lib"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3460 '(defadvice add-to-diary-list (before org-mark-diary-entry activate)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3461 "Make the position visible."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3462 (if (and (boundp 'disable-org-diary) ;; called from org-agenda
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3463 (stringp string)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3464 (buffer-file-name))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3465 (add-text-properties
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3466 0 (length string)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3467 (list 'mouse-face 'highlight
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3468 'keymap org-agenda-keymap
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3469 'help-echo
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3470 (format
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3471 "mouse-2 or RET jump to diary file %s"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3472 (abbreviate-file-name (buffer-file-name)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3473 'org-agenda-diary-link t
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3474 'org-marker (org-agenda-new-marker (point-at-bol)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3475 string))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3476
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3477 (defun org-diary-default-entry ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3478 "Add a dummy entry to the diary.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3479 Needed to avoid empty dates which mess up holiday display."
61312
6939a6683ac3 (org-diary-default-entry): Fixed call to
Carsten Dominik <dominik@science.uva.nl>
parents: 61134
diff changeset
3480 (add-to-diary-list original-date "Org-mode dummy" "" nil))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3481
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482 (defun org-add-file (&optional file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3483 "Add current file to the list of files in variable `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 These are the files which are being checked for agenda entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3485 Optional argument FILE means, use this file instead of the current.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 It is possible (but not recommended) to add this function to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3487 `org-mode-hook'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3488 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 (let* ((file (or file (buffer-file-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491 (if (interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 (error "Buffer is not visiting a file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 (throw 'exit nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 (true-file (file-truename file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 (afile (abbreviate-file-name file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496 (present (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 (equal true-file (file-truename x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 (if (not present)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3501 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3502 (setq org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 (cons afile org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 ;; Make sure custom.el does not end up with Org-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 (customize-save-variable 'org-agenda-files org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 (message "Added file: %s" afile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3509 (message "File was already in list: %s" afile)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3510
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3511 (defun org-remove-file (&optional file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3512 "Remove current file from the list of files in variable `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3513 These are the files which are being checked for agenda entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3514 Optional argument FILE means, use this file instead of the current."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3515 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3516 (let* ((file (or file (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3517 (true-file (file-truename file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518 (afile (abbreviate-file-name file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519 (files (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 (if (equal true-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3522 (file-truename x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523 nil x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3524 org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3525 (if (not (= (length files) (length org-agenda-files)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3526 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3527 (setq org-agenda-files files)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (customize-save-variable 'org-agenda-files org-agenda-files)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3530 (message "Removed file: %s" afile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531 (message "File was not in list: %s" afile))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 (defun org-file-menu-entry (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 (vector file (list 'find-file file) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536 (defun org-get-all-dates (beg end &optional no-ranges force-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 "Return a list of all relevant day numbers from BEG to END buffer positions.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538 If NO-RANGES is non-nil, include only the start and end dates of a range,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 not every single day in the range. If FORCE-TODAY is non-nil, make
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 sure that TODAY is included in the list."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3541 (let (dates date day day1 day2 ts1 ts2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542 (if force-today
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 (setq dates (list (time-to-days (current-time)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3546 (while (re-search-forward org-ts-regexp end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (setq day (time-to-days (org-time-string-to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3548 (substring (match-string 1) 0 10))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3549 (or (memq day dates) (push day dates)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 (unless no-ranges
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552 (while (re-search-forward org-tr-regexp end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553 (setq ts1 (substring (match-string 1) 0 10)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3554 ts2 (substring (match-string 2) 0 10)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555 day1 (time-to-days (org-time-string-to-time ts1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3556 day2 (time-to-days (org-time-string-to-time ts2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557 (while (< (setq day1 (1+ day1)) day2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3558 (or (memq day1 dates) (push day1 dates)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3559 (sort dates '<))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562 (defun org-diary (&rest args)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563 "Returns diary information from org-files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564 This function can be used in an \"sexp\" diary entry in the Emacs calendar.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 It accesses org files and extracts information from those files to be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3566 listed in the diary. The function accepts arguments specifying what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3567 items should be listed. The following arguments are allowed:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569 :timestamp List the headlines of items containing a date stamp or
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3570 date range matching the selected date. Deadlines will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3571 also be listed, on the expiration day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3572
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573 :deadline List any deadlines past due, or due within
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 `org-deadline-warning-days'. The listing occurs only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 in the diary for *today*, not at any other date. If
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 an entry is marked DONE, it is no longer listed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578 :scheduled List all items which are scheduled for the given date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3579 The diary for *today* also contains items which were
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580 scheduled earlier and are not yet marked DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3582 :todo List all TODO items from the org-file. This may be a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 long list - so this is not turned on by default.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3584 Like deadlines, these entires only show up in the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3585 diary for *today*, not at any other date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3586
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 The call in the diary file should look like this:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3589 &%%(org-diary) ~/path/to/some/orgfile.org
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3590
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591 Use a separate line for each org file to check. Or, if you omit the file name,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 all files listed in `org-agenda-files' will be checked automatically:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3594 &%%(org-diary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 If you don't give any arguments (as in the example above), the default
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 arguments (:deadline :scheduled :timestamp) are used. So the example above may
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598 also be written as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 &%%(org-diary :deadline :timestamp :scheduled)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 The function expects the lisp variables `entry' and `date' to be provided
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603 by the caller, because this is how the calendar works. Don't use this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 function from a program - use `org-agenda-get-day-entries' instead."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 (org-agenda-maybe-reset-markers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 (setq args (or args '(:deadline :scheduled :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608 (list entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3609 org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3610 file rtn results)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3611 ;; If this is called during org-agenda, don't return any entries to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3612 ;; the calendar. Org Agenda will list these entries itself.
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3613 (if (boundp 'disable-org-diary) (setq files nil))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 (setq rtn (apply 'org-agenda-get-day-entries file date args))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617 (concat (org-finalize-agenda-entries results) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 (defun org-agenda-get-day-entries (file date &rest args)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 "Does the work for `org-diary' and `org-agenda'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 FILE is the path to a file to be checked for entries. DATE is date like
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 the one returned by `calendar-current-date'. ARGS are symbols indicating
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623 which kind of entries should be extracted. For details about these, see
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 the documentation of `org-diary'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 (setq args (or args '(:deadline :scheduled :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 (let* ((org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 (org-startup-folded nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628 (buffer (if (file-exists-p file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629 ; (find-file-noselect file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630 (org-get-agenda-file-buffer file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 (error "No such file %s" file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 (respect-narrow-p (boundp 'org-respect-restriction))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 arg results rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 (if (not buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635 ;; If file does not exist, make sure an error message ends up in diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 (format "ORG-AGENDA-ERROR: No such org-file %s" file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3638 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639 (let ((case-fold-search nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642 (if respect-narrow-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3643 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 ;; Respect a region to restrict search
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3645 (narrow-to-region (region-beginning) (region-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 ;; If we work for the calendar or many files,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647 ;; get rid of any restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648 (widen))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 (while (setq arg (pop args))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3650 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 ((and (eq arg :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 (equal date (calendar-current-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 (setq rtn (org-agenda-get-todos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655 ((eq arg :timestamp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656 (setq rtn (org-agenda-get-blocks))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 (setq results (append results rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 (setq rtn (org-agenda-get-timestamps))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 ((eq arg :scheduled)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 (setq rtn (org-agenda-get-scheduled))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 ((and (eq arg :deadline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3664 (equal date (calendar-current-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3665 (setq rtn (org-agenda-get-deadlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666 (setq results (append results rtn))))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 results))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3668
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 (defun org-entry-is-done-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3670 "Is the current entry marked DONE?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3671 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3672 (and (re-search-backward "[\r\n]\\*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 (looking-at orb-nl-done-regexp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675 (defun org-at-date-range-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 "It the cursor inside a date range?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3678 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680 (let ((pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 (skip-chars-backward "^<\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 (skip-chars-backward "<")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683 (and (looking-at org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (>= (match-end 0) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3685 (throw 'exit t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686 (skip-chars-backward "^<\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3687 (skip-chars-backward "<")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688 (and (looking-at org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3689 (>= (match-end 0) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 (throw 'exit t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3691 nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3692
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3693 (defun org-agenda-get-todos ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3694 "Return the TODO information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3695 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3696 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3697 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3699 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3700 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3701 (regexp (concat "[\n\r]\\*+ *\\(" org-not-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3702 "[^\n\r]*\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 marker priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704 ee txt pl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3705 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3706 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 (goto-char (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3708 (setq marker (org-agenda-new-marker (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709 txt (org-format-agenda-item "" (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 (+ (org-get-priority txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3712 (if org-todo-kwd-priority-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713 (- org-todo-kwd-max-priority -2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714 (length
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715 (member (match-string 2) org-todo-keywords)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3716 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3718 0 (length txt) (append (list 'org-marker marker 'priority priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3719 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3720 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3721 (push txt ee)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3722 (goto-char (match-end 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3723 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3724
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3725 (defconst org-agenda-no-heading-message
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3726 "No heading for this item in buffer or region")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3727
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3728 (defun org-agenda-get-timestamps ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3729 "Return the date stamp information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3730 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3731 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3732 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3733 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3734 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3735 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3736 (regexp (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3737 (substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3738 (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 (apply 'encode-time ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3742 0 11)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3743 marker deadlinep scheduledp tmp priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744 ee txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3745 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3746 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 (if (not (save-match-data (org-at-date-range-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3749 (setq marker (org-agenda-new-marker (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 tmp (buffer-substring (max (point-min)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751 (- (match-beginning 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 org-ds-keyword-length))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3753 (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 deadlinep (string-match org-deadline-regexp tmp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3755 scheduledp (string-match org-scheduled-regexp tmp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 (goto-char (match-end 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 (format "%s%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 (if deadlinep "Deadline: " "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 (if scheduledp "Scheduled: " ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3765 (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 (setq priority (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 0 (length txt) (append (list 'org-marker marker) props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3770 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 (if deadlinep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3774 (list 'face 'org-warning-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3775 'priority (+ 100 priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3777 (if scheduledp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3779 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 (list 'face 'org-scheduled-today-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3781 priority (+ 99 priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3782 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3783 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3784 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3785 (list 'priority priority) txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3786 (push txt ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3787 (outline-next-heading))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3788 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3789
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3790 (defun org-agenda-get-deadlines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3791 "Return the deadline information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3792 (let* ((wdays org-deadline-warning-days)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3793 (props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3794 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3795 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3796 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3797 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799 (regexp org-deadline-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3800 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3802 d2 diff pos
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3803 ee txt head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3804 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3805 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3806 (setq d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3807 (org-time-string-to-time (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3808 pos (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3809 diff (- d2 d1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3810 ;; When to show a deadline in the calendar:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811 ;; If the expiration is within wdays warning time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3812 ;; Past-due deadlines are only shown on the current date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3813 (if (and (< diff wdays) todayp (not (= diff 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3814 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3815 (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3816 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3817 (goto-char (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3818 (setq head (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3819 (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3820 (progn (skip-chars-forward "^\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3821 (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822 (if (string-match org-looking-at-done-regexp head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823 (setq txt nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3824 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3825 (format "In %3d d.: " diff) head))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3826 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3827 (when txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3828 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3831 (list 'org-marker (org-agenda-new-marker pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3832 'priority (+ (- 10 diff) (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 'face (cond ((<= diff 0) 'org-warning-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 ((<= diff 5) 'font-lock-function-name-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 (t nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3836 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3838 (push txt ee)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839 ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 (defun org-agenda-get-scheduled ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3842 "Return the scheduled information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3843 (let* ((props (list 'face 'org-scheduled-previously-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3844 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3845 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3846 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3847 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3848 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3849 (regexp org-scheduled-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3850 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3851 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3852 d2 diff marker pos
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3853 ee txt head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3854 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3855 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3856 (setq d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3857 (org-time-string-to-time (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3858 pos (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3859 diff (- d2 d1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3860 ;; When to show a scheduled item in the calendar:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3861 ;; If it is on or past the date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3862 (if (and (< diff 0) todayp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3863 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3864 (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3865 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3866 (goto-char (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3867 (setq head (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3868 (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3869 (progn (skip-chars-forward "^\r\n") (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3870 (if (string-match org-looking-at-done-regexp head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3871 (setq txt nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3872 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3873 (format "Sched.%2dx: " (- 1 diff)) head))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3874 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3875 (when txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3876 (setq marker (org-agenda-new-marker pos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3877 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3878 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3879 (append (list 'org-marker marker
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3880 'priority (+ (- 5 diff) (org-get-priority txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3881 props) txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3882 (push txt ee)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3883 ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3884
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3885 (defun org-agenda-get-blocks ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3886 "Return the date-range information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3887 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3888 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3889 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3890 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3891 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3892 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3893 (regexp org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3894 (d0 (calendar-absolute-from-gregorian date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3895 marker ee txt d1 d2 s1 s2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3896 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3897 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 (setq s1 (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3899 s2 (match-string 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3900 d1 (time-to-days (org-time-string-to-time s1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3901 d2 (time-to-days (org-time-string-to-time s2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3902 (if (and (> (- d0 d1) -1) (> (- d2 d0) -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3903 ;; Only allow days between the limits, because the normal
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3904 ;; date stamps will catch the limits.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3905 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3906 (setq marker (org-agenda-new-marker (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3907 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3908 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3909 (goto-char (match-end 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3910 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3911 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3912 (format "(%d/%d): "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3913 (1+ (- d0 d1)) (1+ (- d2 d1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3914 (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3915 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3916 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3917 0 (length txt) (append (list 'org-marker marker
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3918 'priority (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3919 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3920 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3921 (push txt ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3922 (outline-next-heading))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3923 ;; Sort the entries by expiration date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3924 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3925
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3926
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3927 (defun org-format-agenda-item (prefix txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3928 "Format TXT to be inserted into the agenda buffer.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3929 In particular, this indents the lins and adds a category."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3930 (let ((cat (or org-category
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3931 (file-name-sans-extension
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3932 (file-name-nondirectory (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3933 time rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3934 (if (symbolp cat) (setq cat (symbol-name cat)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3935 (setq rtn (format " %-10s %s%s" (concat cat ":") prefix txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3936 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3937 0 2 (list 'category (downcase cat)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3938 'prefix-length (- (length rtn) (length txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939 'time-of-day (org-get-time-of-day rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3940 rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3941 rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 ;; FIXME: Should this be restricted to beginning of string?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3944 (defun org-get-time-of-day (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3945 "Check string S for a time of day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947 (when (and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948 (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949 "\\<\\([012][0-9]\\)\\(:\\([0-6][0-9]\\)\\)?\\([AaPp][Mm]\\)?\\>" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (or (match-beginning 2) (match-beginning 4)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951 (+ (* 100 (+ (string-to-number (match-string 1 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3952 (if (and (match-beginning 4)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3953 (equal (downcase (match-string 4 s)) "pm"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3954 12 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3955 (if (match-beginning 3)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956 (string-to-number (match-string 3 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3957 0)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3958
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3959 (defun org-finalize-agenda-entries (list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3960 "Sort and concatenate the agenda items."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961 (mapconcat 'identity (sort list 'org-entries-lessp) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3963 (defsubst org-cmp-priority (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 "Compare the priorities of string a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965 (let ((pa (or (get-text-property 1 'priority a) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 (pb (or (get-text-property 1 'priority b) 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 (cond ((> pa pb) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 ((< pa pb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3969 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3970
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 (defsubst org-cmp-category (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972 "Compare the string values of categories of strings a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3973 (let ((ca (or (get-text-property 1 'category a) ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3974 (cb (or (get-text-property 1 'category b) "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3975 (cond ((string-lessp ca cb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3976 ((string-lessp cb ca) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3977 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3978
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3979 (defsubst org-cmp-time (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3980 "Compare the time-of-day values of strings a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3981 (let* ((def (if org-sort-agenda-notime-is-late 2401 -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3982 (ta (or (get-text-property 1 'time-of-day a) def))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3983 (tb (or (get-text-property 1 'time-of-day b) def)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3984 (cond ((< ta tb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3985 ((< tb ta) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3986 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3987
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3988 (defun org-entries-lessp (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3989 "Predicate for sorting agenda entries."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3990 (let* ((time-up (org-cmp-time a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3991 (time-down (if time-up (- time-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3992 (priority-up (org-cmp-priority a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3993 (priority-down (if priority-up (- priority-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3994 (category-up (org-cmp-category a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995 (category-down (if category-up (- category-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3996 (category-keep (if category-up +1 nil))) ; FIXME +1 or -1?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3997 (cdr (assoc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3998 (eval (cons 'or org-agenda-sorting-strategy))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3999 '((-1 . t) (1 . nil) (nil . nil))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4000
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4001 (defun org-agenda-show-priority ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4002 "Show the priority of the current item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4003 This priority is composed of the main priority given with the [#A] cookies,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4004 and by additional input from the age of a schedules or deadline entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4005 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4006 (let* ((pri (get-text-property (point-at-bol) 'priority)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4007 (message "Priority is %d" (if pri pri -1000))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4008
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4009 (defun org-agenda-goto ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4010 "Go to the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4011 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4012 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4013 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4014 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4015 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4016 (switch-to-buffer-other-window buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4018 (goto-char pos)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4019 (when (eq major-mode 'org-mode)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4020 (org-show-hidden-entry)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4021 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4022 (and (outline-next-heading)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4023 (org-flag-heading nil)))))) ; show the next heading
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4024
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4025 (defun org-agenda-switch-to ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4026 "Go to the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4027 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4028 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4029 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4030 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4031 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4032 (switch-to-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4033 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4034 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4035 (goto-char pos)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4036 (when (eq major-mode 'org-mode)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4037 (org-show-hidden-entry)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4038 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4039 (and (outline-next-heading)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4040 (org-flag-heading nil)))))) ; show the next heading
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4041
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4042 (defun org-agenda-goto-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4043 "Go to the Org-mode file which contains the deadline at the mouse click."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4044 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4045 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4046 (org-agenda-goto))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4047
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4048 (defun org-agenda-show ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4049 "Display the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4050 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4051 (let ((win (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4052 (org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4053 (select-window win)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4054
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4055 (defun org-agenda-recenter (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4056 "Display the Org-mode file which contains the item at point and recenter."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4057 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 (let ((win (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4059 (org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4060 (recenter arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4061 (select-window win)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4063 (defun org-agenda-show-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 "Display the Org-mode file which contains the deadline at the mouse click."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4065 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4067 (org-agenda-show))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4068
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4069 (defun org-agenda-check-no-diary ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4070 "Check if the entry is a diary link and abort if yes."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4071 (if (get-text-property (point) 'org-agenda-diary-link)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4072 (org-agenda-error)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4073
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4074 (defun org-agenda-error ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4075 (error "Command not allowed in this line."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4076
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 (defun org-agenda-todo ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 "Cycle TODO state of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4080 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 (let* ((props (text-properties-at (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 (col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4083 (marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4085 (pl (get-text-property (point-at-bol) 'prefix-length))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4086 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4087 (pos (marker-position marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4088 (buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4089 newhead)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4090 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4091 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4093 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4094 (org-show-hidden-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4095 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4096 (and (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4097 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4098 (org-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4099 (setq newhead (org-get-heading)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4100 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 (move-to-column pl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102 (if (looking-at ".*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4103 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4104 (replace-match newhead t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4105 (move-to-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4106 (add-text-properties (point-at-bol) (point-at-eol) props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4107 (beginning-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108 (error "Line update did not work"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4110 (defun org-agenda-priority-up ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4111 "Increase the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4112 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4113 (org-agenda-priority 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4114
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4115 (defun org-agenda-priority-down ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4116 "Decrease the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4117 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4118 (org-agenda-priority 'down))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4119
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4120 (defun org-agenda-priority (&optional force-direction)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4121 "Set the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4122 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4123 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4124 (let* ((props (text-properties-at (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4125 (col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4126 (marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4127 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4128 (pl (get-text-property (point-at-bol) 'prefix-length))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4129 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4130 (pos (marker-position marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4131 (buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4132 newhead)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4133 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4134 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4135 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4136 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4137 (org-show-hidden-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4138 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4139 (and (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4140 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4141 (funcall 'org-priority force-direction)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4142 (setq newhead (org-get-heading)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4143 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4144 (move-to-column pl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4145 (if (looking-at ".*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4146 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4147 (replace-match (concat newhead) t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4148 (move-to-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4149 (add-text-properties (point-at-bol) (point-at-eol) props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4150 (beginning-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4151 (error "Line update did not work"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4152
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4153 (defun org-agenda-date-later (arg &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4154 "Change the date of this item to one day later."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4155 (interactive "p")
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4156 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4157 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4158 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4159 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4160 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4161 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4162 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4163 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4164 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4165 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4166 (error "Cannot find time stamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4167 (org-timestamp-change arg (or what 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4168 (message "Time stamp changed to %s" org-last-changed-timestamp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4169
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4170 (defun org-agenda-date-earlier (arg &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4171 "Change the date of this item to one day earlier."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4172 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4173 (org-agenda-date-later (- arg) what))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4174
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4175 (defun org-agenda-date-today (arg)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4176 "Change the date of this item to today."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4177 (interactive "p")
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4178 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4179 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4180 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4181 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4182 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4183 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4184 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4185 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4186 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4187 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4188 (error "Cannot find time stamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4189 (org-time-stamp nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4190 (message "Time stamp changed to %s" org-last-changed-timestamp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4191
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4192 (defun org-get-heading ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4193 "Return the heading of the current entry, without the stars."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4194 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4195 (if (and (re-search-backward "[\r\n]\\*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4196 (looking-at "[\r\n]\\*+[ \t]+\\(.*\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4197 (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4198 "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4199
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4200 (defun org-agenda-diary-entry (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4201 "Make a diary entry, like the `i' command from the calendar.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4202 All the standard commands work: block, weekly etc"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4203 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4204 (require 'diary-lib)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4205 (let* ((char (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4206 (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207 (read-char-exclusive)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208 (cmd (cdr (assoc char
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 '((?d . insert-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4210 (?w . insert-weekly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211 (?m . insert-monthly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 (?y . insert-yearly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4213 (?a . insert-anniversary-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 (?b . insert-block-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (?c . insert-cyclic-diary-entry)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216 (oldf (symbol-function 'calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4217 (point (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4218 (mark (or (mark t) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4219 (unless cmd
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4220 (error "No command associated with <%c>" char))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4221 (unless (and (get-text-property point 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4222 (or (not (equal ?b char))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4223 (get-text-property mark 'day)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4224 (error "Don't know which date to use for diary entry"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4225 ;; We implememnt this by hacking the `calendar-cursor-to-date' function
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4226 ;; and the `calendar-mark-ring' variable. Saves a lot of code.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4227 (let ((calendar-mark-ring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4228 (list (calendar-gregorian-from-absolute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4229 (or (get-text-property mark 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4230 (get-text-property point 'day))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4231 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4232 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4233 (fset 'calendar-cursor-to-date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4234 (lambda (&optional error)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4235 (calendar-gregorian-from-absolute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4236 (get-text-property point 'day))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4237 (call-interactively cmd))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4238 (fset 'calendar-cursor-to-date oldf)))))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4239
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4240
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4241 (defun org-agenda-execute-calendar-command (cmd)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4242 "Execute a calendar command from the agenda, with the date associated to
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4243 the cursor position."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4244 (require 'diary-lib)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4245 (unless (get-text-property (point) 'day)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4246 (error "Don't know which date to use for calendar command"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4247 (let* ((oldf (symbol-function 'calendar-cursor-to-date))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4248 (point (point))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4249 (mark (or (mark t) (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4250 (date (calendar-gregorian-from-absolute
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4251 (get-text-property point 'day)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4252 (displayed-day (extract-calendar-day date))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4253 (displayed-month (extract-calendar-month date))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4254 (displayed-year (extract-calendar-year date)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4255 (unwind-protect
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4256 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4257 (fset 'calendar-cursor-to-date
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4258 (lambda (&optional error)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4259 (calendar-gregorian-from-absolute
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4260 (get-text-property point 'day))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4261 (call-interactively cmd))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4262 (fset 'calendar-cursor-to-date oldf))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4263
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4264 (defun org-agenda-phases-of-moon ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4265 "Display the phases of the moon for 3 month around cursor date."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4266 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4267 (org-agenda-execute-calendar-command 'calendar-phases-of-moon))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4268
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4269 (defun org-agenda-holidays ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4270 "Display the holidays for 3 month around cursor date."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4271 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4272 (org-agenda-execute-calendar-command 'list-calendar-holidays))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4273
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4274 (defun org-agenda-sunrise-sunset (arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4275 "Display sunrise and sunset for the cursor date.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4276 Latitude and longitude can be specified with the variables
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4277 `calendar-latitude' and `calendar-longitude'. When called with prefix
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4278 argument, location will be prompted for."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4279 (interactive "P")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4280 (let ((calendar-longitude (if arg nil calendar-longitude))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4281 (calendar-latitude (if arg nil calendar-latitude))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4282 (calendar-location-name nil))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4283 (org-agenda-execute-calendar-command 'calendar-sunrise-sunset)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4284
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4285 (defun org-agenda-goto-calendar ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4286 "Open the Emacs calendar with the date at the cursor."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4287 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4288 (let* ((day (or (get-text-property (point) 'day)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4289 (error "Don't know which date to open in calendar")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4290 (date (calendar-gregorian-from-absolute day)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4291 (calendar)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4292 (calendar-goto-date date)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4293
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4294 (defun org-agenda-convert-date ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4295 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4296 (let ((day (get-text-property (point) 'day))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4297 date s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4298 (unless day
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4299 (error "Don't know which date to convert"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4300 (setq date (calendar-gregorian-from-absolute day))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4301 (require 'cal-julian)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4302 (require 'cal-hebrew)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4303 (require 'cal-islam)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4304 (require 'cal-french)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4305 (require 'cal-mayan)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4306 (require 'cal-coptic)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4307 (require 'cal-persia)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4308 (require 'cal-china)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4309 (setq s (concat
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4310 "Gregorian: " (calendar-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4311 "Julian: " (calendar-julian-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4312 "Astronomic: " (calendar-astro-date-string date) " (at noon UTC)\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4313 "Hebrew: " (calendar-hebrew-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4314 "Islamic: " (calendar-islamic-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4315 "French: " (calendar-french-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4316 "Maya: " (calendar-mayan-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4317 "Coptic: " (calendar-coptic-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4318 "Persian: " (calendar-persian-date-string date) "\n"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4319 "Chineese: " (calendar-chinese-date-string date) "\n"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4320 (with-output-to-temp-buffer "*Dates*"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4321 (princ s))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4322 (fit-window-to-buffer (get-buffer-window "*Dates*"))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4323
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4324 ;;; Link Stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4325
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4326 (defun org-find-file-at-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4327 "Open file link or URL at mouse."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4328 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4329 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4330 (org-open-at-point 'in-emacs))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4331
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4332 (defun org-open-at-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4333 "Open file link or URL at mouse."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4334 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4335 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4336 (org-open-at-point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4337
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4338 (defun org-open-at-point (&optional in-emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4339 "Open link at or after point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4340 If there is no link at point, this function will search forward up to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4341 the end of the current subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4342 Normally, files will be opened by an appropriate application. If the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4343 optional argument IN-EMACS is non-nil, Emacs will visit the file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4344 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4345 (if (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4346 (org-agenda nil (time-to-days (org-time-string-to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4347 (substring (match-string 1) 0 10)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4348 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4349 (let (type path line (pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4350 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4351 (skip-chars-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4352 (if org-allow-space-in-links "^\t\n\r" "^ \t\n\r"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4353 (if (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4354 org-link-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4355 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4356 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4357 (progn (outline-end-of-subtree) (max pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4358 (error (end-of-line 1) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4359 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4360 (setq type (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4361 path (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4362 (unless path
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4363 (error "No link found."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4364 ;; Remove any trailing spaces in path
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4365 (if (string-match " +\\'" path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4366 (setq path (replace-match "" t t path)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4367
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4368 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4369
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4370 ((string= type "file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4371 (if (string-match ":\\([0-9]+\\)\\'" path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4372 (setq line (string-to-number (match-string 1 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4373 path (substring path 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4374 (org-open-file path in-emacs line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4375
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4376 ((string= type "news")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4377 (org-follow-gnus-link path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4378
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4379 ((string= type "bbdb")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4380 (org-follow-bbdb-link path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4381
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4382 ((string= type "gnus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4383 (let (group article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4384 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4385 (error "Error in Gnus link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4386 (setq group (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4387 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4388 (org-follow-gnus-link group article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4389
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4390 ((string= type "vm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4391 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4392 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4393 (error "Error in VM link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4394 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4395 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4396 ;; in-emacs is the prefix arg, will be interpreted as read-only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4397 (org-follow-vm-link folder article in-emacs)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4398
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4399 ((string= type "wl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4400 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4401 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4402 (error "Error in Wanderlust link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4403 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4404 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4405 (org-follow-wl-link folder article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4406
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4407 ((string= type "rmail")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4408 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4409 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4410 (error "Error in RMAIL link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4411 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4412 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4413 (org-follow-rmail-link folder article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4414
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4415 ((string= type "shell")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4416 (let ((cmd path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4417 (if (or (not org-confirm-shell-links)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4418 (yes-or-no-p (format "Execute \"%s\" in the shell? " cmd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4419 (shell-command cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4420 (error "Abort"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4421
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4422 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4423 (browse-url-at-point)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4424
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4425 (defun org-follow-bbdb-link (name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4426 "Follow a BBDB link to NAME."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4427 (require 'bbdb)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4428 ;; First try an exact match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4429 (bbdb-name (concat "\\`" name "\\'") nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4430 (if (= 0 (buffer-size (get-buffer "*BBDB*")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4431 ;; No exact match - try partial match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4432 (bbdb-name name nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4433
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4434 (defun org-follow-gnus-link (&optional group article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4435 "Follow a Gnus link to GROUP and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4436 (require 'gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4437 (funcall (cdr (assq 'gnus org-link-frame-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4438 (if group (gnus-fetch-group group))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4439 (if article
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4440 (or (gnus-summary-goto-article article nil 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4441 (if (fboundp 'gnus-summary-insert-cached-articles)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4442 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4443 (gnus-summary-insert-cached-articles)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4444 (gnus-summary-goto-article article nil 'force))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4445 (message "Message could not be found.")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4446 ;; (if article (gnus-summary-goto-article article nil 'force)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4447
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4448 (defun org-follow-vm-link (&optional folder article readonly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4449 "Follow a VM link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4450 (require 'vm)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4451 (if (string-match "^//\\([a-zA-Z]+@\\)?\\([^:]+\\):\\(.*\\)" folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4452 ;; ange-ftp or efs or tramp access
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4453 (let ((user (or (match-string 1 folder) (user-login-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4454 (host (match-string 2 folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4455 (file (match-string 3 folder)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4456 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4457 ((featurep 'tramp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4458 ;; use tramp to access the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4459 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4460 (setq folder (format "[%s@%s]%s" user host file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4461 (setq folder (format "/%s@%s:%s" user host file))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4462 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4463 ;; use ange-ftp or efs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4464 (require (if org-xemacs-p 'efs 'ange-ftp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4465 (setq folder (format "/%s@%s:%s" user host file))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4466 (when folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4467 (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4468 (sit-for 0.1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4469 (when article
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4470 (vm-select-folder-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4471 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4472 (let ((case-fold-search t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4473 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4474 (if (not (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4475 (concat "^" "message-id: *" (regexp-quote article))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4476 (error "Could not find the specified message in this folder"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4477 (vm-isearch-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4478 (vm-isearch-narrow)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4479 (vm-beginning-of-message)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4480 (vm-summarize)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4481
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4482 (defun org-follow-wl-link (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4483 "Follow a Wanderlust link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4484 (wl-summary-goto-folder-subr folder 'no-sync t nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4485 (if article (wl-summary-jump-to-msg-by-message-id article))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4486 (wl-summary-redisplay))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4487
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4488 (defun org-follow-rmail-link (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4489 "Follow an RMAIL link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4490 (let (message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4491 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4492 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4493 (rmail (if (string= folder "RMAIL") rmail-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4494 (setq message-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4495 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4496 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4497 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4498 (if (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4499 (concat "^Message-ID:\\s-+" (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4500 (or article "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4501 nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4502 (rmail-what-message))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4503 (if message-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4504 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4505 (rmail (if (string= folder "RMAIL") rmail-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4506 (rmail-show-message message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4507 message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4508 (error "Message not found"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4509
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4510 (defun org-open-file (path &optional in-emacs line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4511 "Open the file at PATH.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4512 First, this expands any special file name abbreviations. Then the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4513 configuration variable `org-file-apps' is checked if it contains an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4514 entry for this file type, and if yes, the corresponding command is launched.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4515 If no application is found, Emacs simply visits the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4516 With optional argument IN-EMACS, Emacs will visit the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4517 If the file does not exist, an error is thrown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4518 (let* ((file (convert-standard-filename (org-expand-file-name path)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4519 (dfile (downcase file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4520 ext cmd apps)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4521 (if (and (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4522 (not org-open-non-existing-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4523 (error "No such file: %s" file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4524 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\.gz\\)$" dfile)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4525 (setq ext (match-string 1 dfile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4526 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4527 (setq ext (match-string 1 dfile))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4528 (setq apps (append org-file-apps (org-default-apps)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4529 (if in-emacs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4530 (setq cmd 'emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4531 (setq cmd (or (cdr (assoc ext apps))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4532 (cdr (assoc t apps)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4533 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4534 ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4535 (setq cmd (format cmd file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4536 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4537 (shell-command (concat cmd " & &"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4538 ((or (stringp cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4539 (eq cmd 'emacs))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4540 (funcall (cdr (assq 'file org-link-frame-setup)) file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4541 (if line (goto-line line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4542 ((consp cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4543 (eval cmd))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4544 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4545
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4546 (defun org-default-apps ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4547 "Return the default applications for this operating system."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4548 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4549 ((eq system-type 'darwin)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4550 org-file-apps-defaults-macosx)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4551 ((eq system-type 'windows-nt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4552 org-file-apps-defaults-windowsnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4553 ((eq system-type 'linux)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4554 org-file-apps-defaults-linux)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4555 (t org-file-apps-defaults-linux)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4556
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4557 (defun org-expand-file-name (path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4558 "Replace special path abbreviations and expand the file name."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4559 (expand-file-name path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4560
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4561
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4562 (defvar org-insert-link-history nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4563 "Minibuffer history for links inserted with `org-insert-link'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4564
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4565 (defvar org-stored-links nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4566 "Contains the links stored with `org-store-link'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4567
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4568 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4569 (defun org-store-link (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4570 "\\<org-mode-map>Store an org-link to the current location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4571 This link can later be inserted into an org-buffer with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4572 \\[org-insert-link].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4573 For some link types, a prefix arg is interpreted:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4574 For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4575 For file links, arg negates `org-line-numbers-in-file-links'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4576 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4577 (let (link cpltxt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4578 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4579
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4580 ((eq major-mode 'bbdb-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4581 (setq link (concat "bbdb:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4582 (bbdb-record-name (bbdb-current-record)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4583
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4584 ((eq major-mode 'calendar-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4585 (let ((cd (calendar-cursor-to-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4586 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4587 (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4588 (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4589 (apply 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4590 (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4591 nil nil nil))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4592
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4593 ((or (eq major-mode 'vm-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4594 (eq major-mode 'vm-presentation-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4595 (and (eq major-mode 'vm-presentation-mode) (vm-summarize))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4596 (vm-follow-summary-cursor)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4597 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4598 (vm-select-folder-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4599 (let* ((message (car vm-message-pointer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4600 (folder (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4601 (subject (vm-su-subject message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4602 (author (vm-su-full-name message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4603 (address (vm-su-from message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4604 (message-id (vm-su-message-id message)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4605 (setq folder (abbreviate-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4606 (if (string-match (concat "^" (regexp-quote vm-folder-directory))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4607 folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4608 (setq folder (replace-match "" t t folder)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4609 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4610 (setq link (concat cpltxt "\n " "vm:" folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4611 "#" message-id)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4612
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4613 ((eq major-mode 'wl-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4614 (let* ((msgnum (wl-summary-message-number))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4615 (message-id (elmo-message-field wl-summary-buffer-elmo-folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4616 msgnum 'message-id))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4617 (wl-message-entity (elmo-msgdb-overview-get-entity
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4618 msgnum (wl-summary-buffer-msgdb)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4619 (author (wl-summary-line-from)) ; FIXME: how to get author name?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4620 (subject "???")) ; FIXME: How to get subject of email?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4621 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4622 (setq link (concat cpltxt "\n " "wl:" wl-summary-buffer-folder-name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4623 "#" message-id))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4624
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4625 ((eq major-mode 'rmail-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4626 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4627 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4628 (rmail-narrow-to-non-pruned-header)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4629 (let ((folder (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4630 (message-id (mail-fetch-field "message-id"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4631 (author (mail-fetch-field "from"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4632 (subject (mail-fetch-field "subject")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4633 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4634 (setq link (concat cpltxt "\n " "rmail:" folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4635 "#" message-id))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4636
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4637 ((eq major-mode 'gnus-group-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4638 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4639 (gnus-group-group-name)) ; version
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4640 ((fboundp 'gnus-group-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4641 (gnus-group-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4642 (t "???"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4643 (if (org-xor arg org-usenet-links-prefer-google)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4644 (setq link (format "http://groups.google.com/groups?group=%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4645 group))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4646 (setq link (concat "gnus:" group)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4647
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4648 ((or (eq major-mode 'gnus-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4649 (eq major-mode 'gnus-article-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4650 (gnus-article-show-summary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4651 (gnus-summary-beginning-of-article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4652 (let* ((group (car gnus-article-current))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4653 (article (cdr gnus-article-current))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4654 (header (gnus-summary-article-header article))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4655 (author (mail-header-from header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4656 (message-id (mail-header-id header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4657 (date (mail-header-date header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4658 (subject (gnus-summary-subject-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4659 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4660 (if (org-xor arg org-usenet-links-prefer-google)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4661 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4662 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4663 cpltxt "\n "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4664 (format "http://groups.google.com/groups?as_umsgid=%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4665 (org-fixup-message-id-for-http message-id))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4666 (setq link (concat cpltxt "\n" "gnus:" group
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4667 "#" (number-to-string article))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4668
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4669 ((eq major-mode 'w3-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4670 (setq link (url-view-url t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4671 ((eq major-mode 'w3m-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4672 (setq link w3m-current-url))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4673
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4674 ((buffer-file-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4675 ;; Just link to this file here.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4676 (setq link (concat "file:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4677 (abbreviate-file-name (buffer-file-name))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4678 ;; Add the line number?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4679 (if (org-xor org-line-numbers-in-file-links arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4680 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4681 (concat link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4682 ":" (int-to-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4683 (+ (if (bolp) 1 0) (count-lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4684 (point-min) (point))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4685 ((interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4686 (error "Cannot link to a buffer which is not visiting a file"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4687 (t (setq link nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4688
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4689 (if (and (interactive-p) link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4690 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4691 (setq org-stored-links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4692 (cons (cons (or cpltxt link) link) org-stored-links))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4693 (message "Stored: %s" (or cpltxt link)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4694 link)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4695
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4696 (defun org-xor (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4697 "Exclusive or."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4698 (or (and a (not b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4699 (and b (not a))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4700
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4701 (defun org-get-header (header)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4702 "Find a header field in the current buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4703 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4704 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4705 (let ((case-fold-search t) s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4706 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4707 ((eq header 'from)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4708 (if (re-search-forward "^From:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4709 (setq s (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4710 (while (string-match "\"" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4711 (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4712 (if (string-match "[<(].*" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4713 (setq s (replace-match "" t t s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4714 ((eq header 'message-id)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4715 (if (re-search-forward "^message-id:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4716 (setq s (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4717 ((eq header 'subject)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4718 (if (re-search-forward "^subject:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4719 (setq s (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4720 (if (string-match "\\`[ \t\]+" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4721 (if (string-match "[ \t\]+\\'" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4722 s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4723
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4724
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4725 (defun org-fixup-message-id-for-http (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4726 "Replace special characters in a message id, so that it can be used
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4727 in an http query."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4728 (while (string-match "<" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4729 (setq s (replace-match "%3C" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4730 (while (string-match ">" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4731 (setq s (replace-match "%3E" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4732 (while (string-match "@" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4733 (setq s (replace-match "%40" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4734 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4735
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4736 (defun org-insert-link (&optional complete-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4737 "Insert a link. At the prompt, enter the link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4738
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4739 Completion can be used to select a link previously stored with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4740 `org-store-link'. When the empty string is entered (i.e. if you just
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4741 press RET at the prompt), the link defaults to the most recently
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4742 stored link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4743
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4744 With a C-u prefix, prompts for a file to link to. The file name can be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4745 selected using completion. The path to the file will be relative to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4746 the current directory if the file is in the current directory or a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4747 subdirectory. Otherwise, the link will be the absolute path as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4748 completed in the minibuffer (i.e. normally ~/path/to/file).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4749
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4750 With two C-u prefixes, enforce an absolute path even if the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4751 is in the current directory or below."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4752 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4753 (let ((link (if complete-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4754 (read-file-name "File: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4755 (completing-read
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4756 "Link: " org-stored-links nil nil nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4757 org-insert-link-history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4758 (or (car (car org-stored-links))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4759 linktxt matched)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4760 (if (or (not link) (equal link ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4761 (error "No links available"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4762 (if complete-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4763 (let ((pwd (file-name-as-directory (expand-file-name "."))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4764 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4765 ((equal complete-file '(16))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4766 (insert "file:" (abbreviate-file-name (expand-file-name link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4767 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4768 (expand-file-name link))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4769 (insert "file:" (match-string 1 (expand-file-name link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4770 (t (insert "file:" link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4771 (setq linktxt (cdr (assoc link org-stored-links)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4772 (if (not org-keep-stored-link-after-insertion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4773 (setq org-stored-links (delq (assoc link org-stored-links)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4774 org-stored-links)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4775 (let ((lines (org-split-string (or linktxt link) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4776 (insert (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4777 (setq matched (string-match org-link-regexp (car lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4778 (setq lines (cdr lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4779 (while lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4780 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4781 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4782 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4783 (looking-at "[ \t]+\\S-"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4784 (indent-relative))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4785 (setq matched (or matched
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4786 (string-match org-link-regexp (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4787 (insert (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4788 (setq lines (cdr lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4789 (unless matched
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4790 (error "Add link type: http(s),ftp,mailto,file,news,bbdb,vm,wl,rmail,gnus, or shell")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4791
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4792 ;;; Hooks for remember.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4793 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4794 (defun org-remember-annotation ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4795 "Return a link to the current location as an annotation for remember.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4796 If you are using Org-mode files as target for data storage with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4797 remember.el, then the annotations should include a link compatible with the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4798 conventions in Org-mode. This function returns such a link."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4799 (org-store-link nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4800
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4801 (defconst org-remember-help
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4802 "Select a destination location for the note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4803 UP/DOWN=headline TAB=cycle visibility [Q]uit RET/<left>/<right>=Store
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4804 RET at beg-of-buf -> Append to file as level 2 headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4805 RET on headline -> Store as sublevel entry to current headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4806 <left>/<right> -> before/after current headline, same headings level")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4807
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4808 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4809 (defun org-remember-handler ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4810 "Store stuff from remember.el into an org file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4811 First prompts for an org file. If the user just presses return, the value
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4812 of `org-default-notes-file' is used.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4813 Then the command offers the headings tree of the selected file in order to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4814 file the text at a specific location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4815 You can either immediately press RET to get the note appended to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4816 file. Or you can use vertical cursor motion and visibility cycling (TAB) to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4817 find a better place. Then press RET or <left> or <right> in insert the note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4818
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4819 Key Cursor position Note gets inserted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4820 -----------------------------------------------------------------------------
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4821 RET buffer-start as level 2 heading at end of file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4822 RET on headline as sublevel of the heading at cursor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4823 RET no heading at cursor position, level taken from context.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4824 Or use prefix arg to specify level manually.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4825 <left> on headline as same level, before current heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4826 <right> on headline as same level, after current heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4827
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4828 So the fastest way to store the note is to press RET RET to append it to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4829 the default file. This way your current train of thought is not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4830 interrupted, in accordance with the principles of remember.el. But with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4831 little extra effort, you can push it directly to the correct location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4832
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4833 Before being stored away, the function ensures that the text has a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4834 headline, i.e. a first line that starts with a \"*\". If not, a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4835 is constructed from the current date and some additional data.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4836
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4837 If the variable `org-adapt-indentation' is non-nil, the entire text is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4838 also indented so that it starts in the same column as the headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4839 \(i.e. after the stars).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4840
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4841 See also the variable `org-reverse-note-order'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4842 (catch 'quit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4843 (let* ((txt (buffer-substring (point-min) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4844 (fastp current-prefix-arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4845 (file (if fastp org-default-notes-file (org-get-org-file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4846 (visiting (find-buffer-visiting file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4847 (org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4848 (org-startup-folded nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4849 spos level indent reversed)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4850 ;; Modify text so that it becomes a nice subtree which can be inserted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4851 ;; into an org tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4852 (let* ((lines (split-string txt "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4853 (first (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4854 (lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4855 (if (string-match "^\\*+" first)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4856 ;; Is already a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4857 (setq indent (make-string (- (match-end 0) (match-beginning 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4858 -1) ?\ ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4859 ;; We need to add a headline: Use time and first buffer line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4860 (setq lines (cons first lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4861 first (concat "* " (current-time-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4862 " (" (remember-buffer-desc) ")")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4863 indent " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4864 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4865 (setq lines (mapcar (lambda (x) (concat indent x)) lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4866 (setq txt (concat first "\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4867 (mapconcat 'identity lines "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4868 ;; Find the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4869 (if (not visiting)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4870 (find-file-noselect file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4871 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4872 (set-buffer (get-file-buffer file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4873 (setq reversed (org-notes-order-reversed-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4874 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4875 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4876 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4877 ;; Ask the User for a location
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4878 (setq spos (if fastp 1 (org-get-location
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4879 (current-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4880 org-remember-help)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4881 (if (not spos) (throw 'quit nil)) ; return nil to show we did
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4882 ; not handle this note
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4883 (goto-char spos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4884 (cond ((bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4885 ;; Put it at the start or end, as level 2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4886 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4887 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4888 (goto-char (if reversed (point-min) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4889 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4890 (org-paste-subtree (or current-prefix-arg 2) txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4891 ((and (org-on-heading-p nil) (not current-prefix-arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4892 ;; Put it below this entry, at the beg/end of the subtree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4893 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4894 (setq level (outline-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4895 (if reversed
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4897 (outline-end-of-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4898 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4899 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4900 (org-paste-subtree (1+ level) txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4901 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4902 ;; Put it right there, with automatic level determined by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4903 ;; org-paste-subtree or from prefix arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4904 (org-paste-subtree current-prefix-arg txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4905 (when remember-save-after-remembering
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4906 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4907 (if (not visiting) (kill-buffer (current-buffer)))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4908 t) ;; return t to indicate that we took care of this note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4909
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4910 (defun org-get-org-file ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4911 "Read a filename, with default directory `org-directory'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4912 (let ((default (or org-default-notes-file remember-data-file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4913 (read-file-name (format "File name [%s]: " default)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4914 (file-name-as-directory org-directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4915 default)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4916
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 (defun org-notes-order-reversed-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4918 "Check if the current file should receive notes in reversed order."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4919 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4920 ((not org-reverse-note-order) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4921 ((eq t org-reverse-note-order) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4922 ((not (listp org-reverse-note-order)) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4923 (t (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924 (let ((all org-reverse-note-order)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4925 entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4926 (while (setq entry (pop all))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4927 (if (string-match (car entry) (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4928 (throw 'exit (cdr entry))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4929 nil)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4930
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4931 ;;; Tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4932
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4933 ;; Watch out: Here we are talking about two different kind of tables.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4934 ;; Most of the code is for the tables created with the Org-mode table editor.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4935 ;; Sometimes, we talk about tables created and edited with the table.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936 ;; Emacs package. We call the former org-type tables, and the latter
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4937 ;; table.el-type tables.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4938
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4939 ;; We use a before-change function to check if a table might need
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4940 ;; an update.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4941 (defvar org-table-may-need-update t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4942 "Indicates of a table might need an update.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4943 This variable is set by `org-before-change-function'. `org-table-align'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4944 sets it back to nil.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4945
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4946 (defun org-before-change-function (beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4947 "Every change indicates that a table might need an update."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4948 (setq org-table-may-need-update t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4949
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4950 (defconst org-table-line-regexp "^[ \t]*|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4951 "Detects an org-type table line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4952 (defconst org-table-dataline-regexp "^[ \t]*|[^-]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4953 "Detects an org-type table line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4954 (defconst org-table-hline-regexp "^[ \t]*|-"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4955 "Detects an org-type table hline.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4956 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4957 "Detects a table-type table hline.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4958 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4959 "Detects an org-type or table-type table")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4960 (defconst org-table-border-regexp "^[ \t]*[^| \t]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4961 "Searching from within a table (any type) this finds the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4962 outside the table.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4963 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4964 "Searching from within a table (any type) this finds the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4965 outside the table.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4966
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4967 (defun org-table-create-with-table.el ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4968 "Use the table.el package to insert a new table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4969 If there is already a table at point, convert between Org-mode tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4970 and table.el tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4971 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4972 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4973 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4974 ((org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4975 (if (y-or-n-p "Convert table to Org-mode table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4976 (org-table-convert)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4977 ((org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4978 (if (y-or-n-p "Convert table to table.el table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4979 (org-table-convert)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4980 (t (call-interactively 'table-insert))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4981
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4982 (defun org-table-create (&optional size)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4983 "Query for a size and insert a table skeleton.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4984 SIZE is a string Columns x Rows like for example \"3x2\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4986 (unless size
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4987 (setq size (read-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4988 (concat "Table size Columns x Rows [e.g. "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4989 org-table-default-size "]: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4990 "" nil org-table-default-size)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4991
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4992 (let* ((pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4993 (indent (make-string (current-column) ?\ ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4994 (split (org-split-string size " *x *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4995 (rows (string-to-number (nth 1 split)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4996 (columns (string-to-number (car split)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4997 (line (concat (apply 'concat indent "|" (make-list columns " |"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4998 "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4999 (if (string-match "^[ \t]*$" (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5000 (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5001 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5002 (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5003 (mapcar (lambda (x) (insert line)) (make-list rows t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5004 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5005 (if (> rows 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5006 ;; Insert a hline after the first row.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5007 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5008 (end-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5009 (insert "\n|-")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5010 (goto-char pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5011 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5012
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5013 (defun org-table-convert-region (beg0 end0 nspace)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5014 "Convert region to a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5015 The region goes from BEG0 to END0, but these borders will be moved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5016 slightly, to make sure a beginning of line in the first line is included.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5017 When NSPACE is non-nil, it indicates the minimum number of spaces that
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5018 separate columns (default: just one space)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5019 (let* ((beg (min beg0 end0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5020 (end (max beg0 end0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5021 (tabsep t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5022 re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5025 (setq beg (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5026 (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5027 (if (bolp) (backward-char 1) (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028 (setq end (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029 ;; Lets see if this is tab-separated material. If every nonempty line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5030 ;; contains a tab, we will assume that it is tab-separated material
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5031 (if nspace
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5032 (setq tabsep nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5033 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5034 (and (re-search-forward "^[^\n\t]+$" end t) (setq tabsep nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5035 (if nspace (setq tabsep nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5036 (if tabsep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5037 (setq re "^\\|\t")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5038 (setq re (format "^ *\\| *\t *\\| \\{%d,\\}"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5039 (max 1 (prefix-numeric-value nspace)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5040 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5041 (while (re-search-forward re end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5042 (replace-match "|" t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5043 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5044 (insert " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5045 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5046
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5047 (defun org-table-import (file arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5048 "Import FILE as a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5049 The file is assumed to be tab-separated. Such files can be produced by most
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5050 spreadsheet and database applications. If no tabs (at least one per line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5051 are found, lines will be split on whitespace into fields."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5052 (interactive "f\nP")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5053 (or (bolp) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5054 (let ((beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5055 (pm (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5056 (insert-file-contents file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5057 (org-table-convert-region beg (+ (point) (- (point-max) pm)) arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5058
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5059 (defun org-table-export ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5060 "Export table as a tab-separated file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5061 Such a file can be imported into a spreadsheet program like Excel."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5062 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5063 (let* ((beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5064 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5065 (table (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5066 (file (read-file-name "Export table to: "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5067 buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5068 (unless (or (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5069 (y-or-n-p (format "Overwrite file %s? " file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5070 (error "Abort"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5071 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5072 (find-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5073 (setq buf (current-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5074 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5075 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5076 (insert table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5077 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5078 (while (re-search-forward "^[ \t]*|[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5079 (replace-match "" t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5080 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5081 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5082 (while (re-search-forward "[ \t]*|[ \t]*$" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5083 (replace-match "" t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5084 (goto-char (min (1+ (point)) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5085 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5086 (while (re-search-forward "^-[-+]*$" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5087 (replace-match "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5088 (if (looking-at "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5089 (delete-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5090 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5091 (while (re-search-forward "[ \t]*|[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5092 (replace-match "\t" t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5093 (save-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5094 (kill-buffer buf)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5095
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5096 (defvar org-table-aligned-begin-marker (make-marker)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5097 "Marker at the beginning of the table last aligned.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5098 Used to check if cursor still is in that table, to minimize realignment.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5099 (defvar org-table-aligned-end-marker (make-marker)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5100 "Marker at the end of the table last aligned.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5101 Used to check if cursor still is in that table, to minimize realignment.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5102 (defvar org-table-last-alignment nil
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5103 "List of flags for flushright alignment, from the last re-algnment.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5104 This is being used to correctly align a single field after TAB or RET.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5105 ;; FIXME: The following is currently not used.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5106 (defvar org-table-last-column-widths nil
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5107 "List of max width of ffields in each column.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5108 This is being used to correctly align a single field after TAB or RET.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5109
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5110
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5111 (defun org-table-align (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5112 "Align the table at point by aligning all vertical bars."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5113 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5114 (let* (
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5115 ;; Limits of table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5116 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5117 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5118 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5119 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5120 (colpos (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5121 (winstart (window-start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5122 text lines (new "") lengths l typenums ty fields maxfields i
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5123 column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5124 (indent "") cnt frac
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5125 rfmt hfmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5126 (spaces (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5127 org-table-spaces-around-invisible-separators
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5128 org-table-spaces-around-separators))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5129 (sp1 (car spaces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5130 (sp2 (cdr spaces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5131 (rfmt1 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5132 (make-string sp2 ?\ ) "%%%s%ds" (make-string sp1 ?\ ) "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5133 (hfmt1 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5134 (make-string sp2 ?-) "%s" (make-string sp1 ?-) "+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5135 emptystrings)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5136 (untabify beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5137 ;; (message "Aligning table...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5138 ;; Get the rows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5139 (setq lines (org-split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5140 (buffer-substring-no-properties beg end) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5141 ;; Store the indentation of the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5142 (if (string-match "^ *" (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5143 (setq indent (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5144 ;; Mark the hlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5145 (setq lines (mapcar (lambda (l) (if (string-match "^ *|-" l) nil l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5146 lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5147 ;; Get the data fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5148 (setq fields (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5149 (lambda (l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5150 (org-split-string l " *| *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5151 (delq nil (copy-sequence lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5152 ;; How many fields in the longest line?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5153 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5154 (setq maxfields (apply 'max (mapcar 'length fields)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5155 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5156 (kill-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5157 (org-table-create org-table-default-size)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5158 (error "Empty table - created default table")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5159 ;; A list of empty string to fill any short rows on output
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5160 (setq emptystrings (make-list maxfields ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5161 ;; Get the maximum length of a field and the most common datatype
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5162 ;; for each column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5163 (setq i -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5164 (while (< (setq i (1+ i)) maxfields) ;; Loop over all columns
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5165 (setq column (mapcar (lambda (x) (or (nth i x) "")) fields))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5166 ;; maximum length
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5167 (push (apply 'max 1 (mapcar 'length column)) lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5168 ;; compute the fraction stepwise, ignoring empty fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5169 (setq cnt 0 frac 0.0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5170 (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5171 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5172 (if (equal x "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5173 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5174 (setq frac ( / (+ (* frac cnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5175 (if (string-match org-table-number-regexp x) 1 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5176 (setq cnt (1+ cnt))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5177 column)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5178 (push (>= frac org-table-number-fraction) typenums))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5179 (setq lengths (nreverse lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5180 typenums (nreverse typenums))
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5181 (setq org-table-last-alignment typenums
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5182 org-table-last-column-widths lengths)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5183 ;; Compute the formats needed for output of the table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5184 (setq rfmt (concat indent "|") hfmt (concat indent "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5185 (while (setq l (pop lengths))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5186 (setq ty (if (pop typenums) "" "-")) ; number types flushright
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5187 (setq rfmt (concat rfmt (format rfmt1 ty l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5188 hfmt (concat hfmt (format hfmt1 (make-string l ?-)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5189 (setq rfmt (concat rfmt "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5190 hfmt (concat (substring hfmt 0 -1) "|\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5191 ;; Produce the new table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5192 (while lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5193 (setq l (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5194 (if l
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5195 (setq new (concat new (apply 'format rfmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5196 (append (pop fields) emptystrings))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5197 (setq new (concat new hfmt))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5198 ;; Replace the old one
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5199 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5200 (move-marker end nil)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5201 (move-marker org-table-aligned-begin-marker (point))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5202 (insert new)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5203 (move-marker org-table-aligned-end-marker (point))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5204 ;; Try to move to the old location (approximately)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5205 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5206 (set-window-start (selected-window) winstart 'noforce)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5207 (org-table-goto-column colpos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5208 (setq org-table-may-need-update nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5209 (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5210 (org-table-add-invisible-to-vertical-lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5211 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5212
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5213 (defun org-table-begin (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5214 "Find the beginning of the table and return its position.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5215 With argument TABLE-TYPE, go to the beginning of a table.el-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5216 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5217 (if (not (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5218 (if table-type org-table-any-border-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5219 org-table-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5220 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5221 (error "Can't find beginning of table")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5222 (goto-char (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5223 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5224 (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5225
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5226 (defun org-table-end (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5227 "Find the end of the table and return its position.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5228 With argument TABLE-TYPE, go to the end of a table.el-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5229 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5230 (if (not (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5231 (if table-type org-table-any-border-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5232 org-table-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5233 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5234 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5235 (goto-char (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5236 (point-marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5237
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5238 (defun org-table-justify-field-maybe ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5239 "Justify the current field, text to left, number to right."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5240 (cond
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5241 (org-table-may-need-update) ; Realignment will happen anyway, don't bother
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5242 ((org-at-table-hline-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5243 ;; This is pretty stupid, but I don't know how to deal with hlines
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5244 (setq org-table-may-need-update t))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5245 ((or (not (equal (marker-buffer org-table-aligned-begin-marker)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5246 (current-buffer)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5247 (< (point) org-table-aligned-begin-marker)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5248 (>= (point) org-table-aligned-end-marker))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5249 ;; This is not the same table, force a full re-align
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5250 (setq org-table-may-need-update t))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5251 (t ;; realign the current field, based on previous full realign
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5252 (let* ((pos (point)) s org-table-may-need-update
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5253 (col (org-table-current-column))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5254 (num (nth (1- col) org-table-last-alignment))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5255 l f)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5256 (when (> col 0)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5257 (skip-chars-backward "^|\n")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5258 (if (looking-at " *\\([^|\n]*?\\) *|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5259 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5260 (setq s (match-string 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5261 l (max 1 (- (match-end 0) (match-beginning 0) 3)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5262 (setq f (format (if num " %%%ds |" " %%-%ds |") l))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5263 (replace-match (format f s t t)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5264 (setq org-table-may-need-update t))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5265 (goto-char pos))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5266
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5267 (defun org-table-next-field (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5268 "Go to the next field in the current table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5269 Before doing so, re-align the table if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5270 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5271 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5272 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5273 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5274 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5275 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5276 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5277 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5278 (re-search-forward "|" (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5279 (if (looking-at "[ \t]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5280 (re-search-forward "|" (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5281 (if (looking-at "-")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5282 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5283 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5284 (org-table-insert-row 'below))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5285 (if (looking-at " ") (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5286 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5287 (org-table-insert-row 'below))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5288
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5289 (defun org-table-previous-field (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5290 "Go to the previous field in the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5291 Before doing so, re-align the table if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5292 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5293 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5294 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5295 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5296 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5297 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5298 (re-search-backward "|" (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5299 (re-search-backward "|" (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5300 (while (looking-at "|\\(-\\|[ \t]*$\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5301 (re-search-backward "|" (org-table-begin)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5302 (if (looking-at "| ?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5303 (goto-char (match-end 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5304
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5305 (defun org-table-next-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5306 "Go to the next row (same column) in the current table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5307 Before doing so, re-align the table if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5308 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5309 (if (or (looking-at "[ \t]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5310 (save-excursion (skip-chars-backward " \t") (bolp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5311 (newline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5312 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5313 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5314 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5315 (let ((col (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5316 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5317 (if (or (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5318 (org-at-table-hline-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5319 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5320 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5321 (org-table-insert-row 'below)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5322 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5323 (skip-chars-backward "^|\n\r")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5324 (if (looking-at " ") (forward-char 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5325
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5326 (defun org-table-copy-down (n)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5327 "Copy a field down in the current column.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5328 If the field at the cursor is empty, copy into it the content of the nearest
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5329 non-empty field above. With argument N, use the Nth non-empty field.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5330 If the current fields is not empty, it is copied down to the next row, and
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5331 the cursor is moved with it. Therefore, repeating this command causes the
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5332 column to be filled row-by-row.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5333 If the variable `org-table-copy-increment' is non-nil and the field is an
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5334 integer, it will be incremented while copying."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5335 (interactive "p")
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5336 (let* ((colpos (org-table-current-column))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5337 (field (org-table-get-field))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5338 (non-empty (string-match "[^ \t]" field))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5339 (beg (org-table-begin))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5340 txt)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5341 (org-table-check-inside-data-field)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5342 (if non-empty (progn (org-table-next-row) (org-table-blank-field)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5343 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5344 (setq txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5345 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5346 (while (progn (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5347 (re-search-backward org-table-dataline-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5348 beg t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5349 (org-table-goto-column colpos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5350 (if (and (looking-at
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5351 "|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5352 (= (setq n (1- n)) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5353 (throw 'exit (match-string 1)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5354 (progn
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5355 (if (and org-table-copy-increment
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5356 (string-match "^[0-9]+$" txt))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5357 (setq txt (format "%d" (+ (string-to-int txt) 1))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5358 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5359 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5360 (error "No non-empty field found"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5361
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5362 (defun org-table-check-inside-data-field ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5363 "Is point inside a table data field?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5364 I.e. not on a hline or before the first or after the last column?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5365 (if (or (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5366 (= (org-table-current-column) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5367 (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5368 (looking-at "[ \t]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5369 (error "Not in table data field")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5370
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5371 (defun org-table-blank-field ()
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5372 "Blank the current table field or active region."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5373 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5374 (org-table-check-inside-data-field)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5375 (if (and (interactive-p) (org-region-active-p))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5376 (let (org-table-clip)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5377 (org-table-cut-region))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5378 (skip-chars-backward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5379 (backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5380 (if (looking-at "|[^|]+")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5381 (let* ((pos (match-beginning 0))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5382 (match (match-string 0))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5383 (len (length match)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5384 (replace-match (concat "|" (make-string (1- len) ?\ )))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5385 (goto-char (+ 2 pos))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5386 (substring match 1)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5387
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5388 (defun org-table-get-field (&optional n replace)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5389 "Return the value of the field in column N of current row.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5390 N defaults to current field.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5391 If REPLACE is a string, replace field with this value. The return value
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5392 is always the old value."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5393 (and n (org-table-goto-column n))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5394 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5395 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5396 (if (looking-at "|[^|\r\n]*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5397 (let* ((pos (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5398 (len (length (match-string 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5399 (val (buffer-substring (1+ pos) (match-end 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5400 (if replace
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5401 (replace-match (concat "|" replace)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5402 (goto-char (+ 2 pos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403 val)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5404
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5405 (defun org-table-current-column ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5406 "Find out which column we are in.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5407 When called interactively, column is also displayed in echo area."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5409 (if (interactive-p) (org-table-check-inside-data-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5410 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411 (let ((cnt 0) (pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5412 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5413 (while (search-forward "|" pos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5414 (setq cnt (1+ cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5415 (if (interactive-p) (message "This is table column %d" cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5416 cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5417
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5418 (defun org-table-goto-column (n &optional on-delim force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419 "Move the cursor to the Nth column in the current table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5420 With optional argument ON-DELIM, stop with point before the left delimiter
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5421 of the field.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5422 If there are less than N fields, just go to after the last delimiter.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5423 However, when FORCE is non-nil, create new columns if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5424 (let ((pos (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5426 (when (> n 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5427 (while (and (> (setq n (1- n)) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5428 (or (search-forward "|" pos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5429 (and force
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5430 (progn (end-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5431 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5432 (insert " |")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5433 (bachward-char 2) t)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5434 (when (and force (not (looking-at ".*|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5435 (save-excursion (end-of-line 1) (insert "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5436 (if on-delim
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5437 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5438 (if (looking-at " ") (forward-char 1))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5439
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5440 (defun org-at-table-p (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5441 "Return t if the cursor is inside an org-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5442 (if org-enable-table-editor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5443 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5444 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5445 (looking-at (if table-type org-table-any-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5446 org-table-line-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5447 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5448
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5449 (defun org-table-recognize-table.el ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5450 "If there is a table.el table nearby, recognize it and move into it."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5451 (if org-table-tab-recognizes-table.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5452 (if (org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5453 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5454 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5455 (if (looking-at org-table-dataline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5456 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5457 (if (looking-at org-table1-hline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5458 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5459 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5460 (if (looking-at org-table-any-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5461 (beginning-of-line -1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5462 (if (re-search-forward "|" (org-table-end t) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5463 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5464 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5465 (if (table--at-cell-p (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5466 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5467 (message "recognizing table.el table...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5468 (table-recognize-table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5469 (message "recognizing table.el table...done")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5470 (error "This should not happen..."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5471 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5472 nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5473 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5474
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5475 (defun org-at-table.el-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5476 "Return t if the cursor is inside a table.el-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5477 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5478 (if (org-at-table-p 'any)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5479 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5480 (goto-char (org-table-begin 'any))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5481 (looking-at org-table1-hline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5482 nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5483
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5484 (defun org-at-table-hline-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5485 "Return t if the cursor is inside a hline in a table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5486 (if org-enable-table-editor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5487 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5488 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489 (looking-at org-table-hline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5490 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5491
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5492 (defun org-table-insert-column (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5493 "Insert a new column into the table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5494 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5495 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5496 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5497 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5498 (let* ((col (max 1 (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5499 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5500 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5501 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5502 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5503 (colpos col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5504 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5505 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5506 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5507 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5508 (org-table-goto-column col t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5509 (insert "| "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5510 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5511 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5512 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5513 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5514 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5515
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5516 (defun org-table-find-dataline ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5517 "Find a dataline in the current table, which is needed for column commands."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5518 (if (and (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5519 (not (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5520 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5521 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5522 (end (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5523 (move-to-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5524 (while (and (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5525 (or (not (= (current-column) col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5526 (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5527 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5528 (move-to-column col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5529 (if (and (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5530 (not (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5531 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5532 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5533 "Please position cursor in a data line for column operations")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5534
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5535 (defun org-table-delete-column (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5536 "Insert a new column into the table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5537 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5538 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5539 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5540 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5541 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5542 (let* ((col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5543 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5544 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5545 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5546 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5547 (colpos col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5548 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5549 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5550 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5551 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5552 (org-table-goto-column col t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5553 (and (looking-at "|[^|\n]+|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5554 (replace-match "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5555 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5556 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5557 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5558 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5559 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5560
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5561 (defun org-table-move-column-right ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5562 "Move column to the right."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5563 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5564 (org-table-move-column nil))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5565 (defun org-table-move-column-left ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5566 "Move column to the left."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5567 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5568 (org-table-move-column 'left))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5569
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5570 (defun org-table-move-column (&optional left)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5571 "Move the current column to the right. With arg LEFT, move to the left."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5572 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5573 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5574 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5575 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5577 (let* ((col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5578 (col1 (if left (1- col) col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5579 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5580 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5582 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5583 (colpos (if left (1- col) (1+ col))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5584 (if (and left (= col 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5585 (error "Cannot move column further left"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5586 (if (and (not left) (looking-at "[^|\n]*|[^|\n]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5587 (error "Cannot move column further right"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5588 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5589 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5590 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5591 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5592 (org-table-goto-column col1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5593 (and (looking-at "|\\([^|\n]+\\)|\\([^|\n]+\\)|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5594 (replace-match "|\\2|\\1|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5595 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5596 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5597 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5598 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5599 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5600
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5601 (defun org-table-move-row-down ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5602 "Move table row down."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5603 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5604 (org-table-move-row nil))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5605 (defun org-table-move-row-up ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5606 "Move table row down."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5607 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5608 (org-table-move-row 'up))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5609
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5610 (defun org-table-move-row (&optional up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5611 "Move the current table line down. With arg UP, move it up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5612 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5613 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5614 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5615 (tonew (if up 0 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5616 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5617 (beginning-of-line tonew)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5618 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5619 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5620 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5621 (error "Cannot move row further.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5622 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5623 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5624 (setq pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5625 (setq txt (buffer-substring (point) (1+ (point-at-eol))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5626 (delete-region (point) (1+ (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5627 (beginning-of-line tonew)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5628 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5629 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5630 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5631
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5632 (defun org-table-insert-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5633 "Insert a new row above the current line into the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5634 With prefix ARG, insert below the current line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5635 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5636 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5637 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5638 (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5639 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5640 (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5641 (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5642 (beginning-of-line (if arg 2 1))
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5643 (let (org-table-may-need-update)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5644 (apply 'insert-before-markers line)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5645 (insert-before-markers "\n"))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5646 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5647 (re-search-forward "| ?" (point-at-eol) t)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5648 (and org-table-may-need-update (org-table-align))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5649
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5650 (defun org-table-insert-hline (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5651 "Insert a horizontal-line below the current line into the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5652 With prefix ARG, insert above the current line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5653 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5654 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5655 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5656 (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5657 (col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5658 start)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5659 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5660 (setq line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5661 (mapcar (lambda (x) (if (member x '(?| ?+))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5662 (prog1 (if start ?+ ?|) (setq start t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5663 (if start ?- ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5664 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5665 (setq line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5666 (mapcar (lambda (x) (if (equal x ?|)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5667 (prog1 (if start ?+ ?|) (setq start t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5668 (if start ?- ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5669 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5670 (beginning-of-line (if arg 1 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5671 (apply 'insert line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5672 (if (equal (char-before (point)) ?+)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5673 (progn (backward-delete-char 1) (insert "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5674 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5675 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5676 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5677
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5678 (defun org-table-kill-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5679 "Delete the current row or horizontal line from the table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5680 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5681 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5682 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5683 (let ((col (current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5684 (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5685 (if (not (org-at-table-p)) (beginning-of-line 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5686 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5687
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5688
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5689 (defun org-table-cut-region (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5690 "Copy region in table to the clipboard and blank all relevant fields."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5691 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5692 (org-table-copy-region 'cut))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5693
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5694 (defvar org-table-clip nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5695 "Clipboard for table regions")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5696
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5697 (defun org-table-copy-region (&optional cut)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5698 "Copy rectangular region in table to clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5699 A special clibbooard is used which can only be accessed
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5700 with `org-table-paste-rectangle'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5701 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5702 (unless (org-region-active-p) (error "No active region"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5703 (let* ((beg (region-beginning))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5704 (end (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5705 l01 c01 l02 c02 l1 c1 l2 c2 ic1 ic2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5706 region cols
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5707 (rpl (if cut " " nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5708 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5709 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5710 (setq l01 (count-lines (point-min) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5711 c01 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5712 (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5713 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5714 (setq l02 (count-lines (point-min) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5715 c02 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5716 (setq l1 (min l01 l02) l2 (max l01 l02)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5717 c1 (min c01 c02) c2 (max c01 c02))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5718 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5719 (while t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5720 (catch 'nextline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5721 (if (> l1 l2) (throw 'exit t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5722 (goto-line l1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5723 (if (org-at-table-hline-p) (throw 'nextline (setq l1 (1+ l1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5724 (setq cols nil ic1 c1 ic2 c2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5725 (while (< ic1 (1+ ic2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5726 (push (org-table-get-field ic1 rpl) cols)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5727 (setq ic1 (1+ ic1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5728 (push (nreverse cols) region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5729 (setq l1 (1+ l1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5730 (setq org-table-clip (nreverse region))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5731 (if cut (org-table-align))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5732
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5733 (defun org-table-paste-rectangle (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5734 "Paste a rectangluar region into a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5735 The upper right corner ends up in the current field. All involved fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5736 will be overwritten. If the rectangle does not fit into the present table,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5737 the table is enlarged as needed. The process ignores horizontal separator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5738 lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5739 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5740 (unless (and org-table-clip (listp org-table-clip))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5741 (error "First cut/copy a region to paste!"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5742 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5743 (let* ((clip org-table-clip)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5744 (line (count-lines (point-min) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5745 (col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5746 (l line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5747 (org-enable-table-editor t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5748 (org-table-automatic-realign nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5749 c cols field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5750 (while (setq cols (pop clip))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5751 (while (org-at-table-hline-p) (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5752 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5753 (progn (end-of-line 0) (org-table-next-field)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5754 (setq c col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5755 (while (setq field (pop cols))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5756 (org-table-goto-column c nil 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5757 (org-table-get-field nil field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5758 (setq c (1+ c)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5759 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5760 (goto-line line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5761 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5762 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5763
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5764 (defun org-table-convert ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5765 "Convert from org-mode table to table.el and back.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5766 Obviously, this only works within limits. When an Org-mode table is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5767 converted to table.el, all horizontal separator lines get lost, because
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5768 table.el uses these as cell boundaries and has no notion of horizontal lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5769 A table.el table can be converted to an Org-mode table only if it does not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5770 do row or column spanning. Multiline cells will become multiple cells.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5771 Beware, Org-mode does not test if the table can be successfully converted - it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5772 blindly applies a recipe that works for simple tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5773 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5774 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5775 (if (org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5776 ;; convert to Org-mode table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5777 (let ((beg (move-marker (make-marker) (org-table-begin t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5778 (end (move-marker (make-marker) (org-table-end t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5779 (table-unrecognize-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5780 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5781 (while (re-search-forward "^\\([ \t]*\\)\\+-.*\n" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5782 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5783 (goto-char beg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5784 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5785 ;; convert to table.el table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5786 (let ((beg (move-marker (make-marker) (org-table-begin)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5787 (end (move-marker (make-marker) (org-table-end))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5788 ;; first, get rid of all horizontal lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5789 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5790 (while (re-search-forward "^\\([ \t]*\\)|-.*\n" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5791 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5792 ;; insert a hline before first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5793 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5794 (org-table-insert-hline 'above)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5795 ;; insert a hline after each line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5796 (while (progn (beginning-of-line 2) (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5797 (org-table-insert-hline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5798 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5799 (setq end (move-marker end (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5800 ;; replace "+" at beginning and ending of hlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5801 (while (re-search-forward "^\\([ \t]*\\)|-" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5802 (replace-match "\\1+-"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5803 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5804 (while (re-search-forward "-|[ \t]*$" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5805 (replace-match "-+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5806 (goto-char beg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5807
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5808 (defun org-table-wrap-region (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5809 "Wrap several fields in a column like a paragraph.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5810 This is useful if you'd like to spread the contents of a field over several
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5811 lines, in order to keep the table compact.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5812
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5813 If there is an active region, and both point and mark are in the same column,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5814 the text in the column is wrapped to minimum width for the given number of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5815 lines. Generally, this makes the table more compact. A prefix ARG may be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5816 used to change the number of desired lines. For example, `C-2 C-c C-q'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5817 formats the selected text to two lines. If the region was longer than 2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5818 lines, the remaining lines remain empty. A negative prefix argument reduces
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5819 the current number of lines by that amount. The wrapped text is pasted back
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5820 into the table. If you formatted it to more lines than it was before, fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5821 further down in the table get overwritten - so you might need to make space in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5822 the table first.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5823
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5824 If there is no region, the current field is split at the cursor position and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5825 the text fragment to the right of the cursor is prepended to the field one
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5826 line down.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5827
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5828 If there is no region, but you specify a prefix ARG, the current field gets
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5829 blank, and the content is appended to the field above."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5830 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5831 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5832 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5833 ;; There is a region: fill as a paragraph
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5834 (let ((beg (region-beginning))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5835 nlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5836 (org-table-cut-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5837 (if (> (length (car org-table-clip)) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5838 (error "Region must be limited to single columm"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5839 (setq nlines (if arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5840 (if (< arg 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5841 (+ (length org-table-clip) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5842 arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5843 (length org-table-clip)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5844 (setq org-table-clip
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5845 (mapcar 'list (org-wrap (mapconcat 'car org-table-clip " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5846 nil nlines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5847 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5848 (org-table-paste-rectangle))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5849 ;; No region, split the current field at point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5850 (if arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5851 ;; combine with field above
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5852 (let ((s (org-table-blank-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5853 (col (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5854 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5855 (while (org-at-table-hline-p) (beginning-of-line 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5856 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5857 (skip-chars-forward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5858 (skip-chars-backward " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5859 (insert " " (org-trim s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5860 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5861 ;; split field
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5862 (when (looking-at "\\([^|]+\\)+|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5863 (let ((s (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5864 (replace-match " |")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5865 (goto-char (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5866 (org-table-next-row)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5867 (insert (org-trim s) " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5868 (org-table-align))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5869
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5870 (defun org-trim (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5871 "Remove whitespace at beginning and end of string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5872 (if (string-match "^[ \t]+" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5873 (if (string-match "[ \t]+$" s) (setq s (replace-match "" t t s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5874
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5875 (defun org-wrap (string &optional width lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5876 "Wrap string to either a number of lines, or a with in characters.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5877 If WIDTH is non-nil, the string is wrapped to that width, however many lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5878 that costs. If there is a work longer than WIDTH, the text is actually
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5879 wrapped to the length of that word.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5880 IF WIDTH is nil and LINES is non-nil, the string is forced into at mot that
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5881 many lines, whatever width that takes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5882 The return value is a list of lines, without newlines at the end."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5883 (let* ((words (org-split-string string "[ \t\n]+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5884 (maxword (apply 'max (mapcar 'length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5885 (black (apply '+ (mapcar 'length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5886 (total (+ black (length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5887 w ll)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5888 (cond (width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5889 (org-do-wrap words (max maxword width)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5890 (lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5891 (setq w maxword)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5892 (setq ll (org-do-wrap words maxword))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5893 (if (<= (length ll) lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5894 ll
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5895 (setq ll words)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5896 (while (> (length ll) lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5897 (setq w (1+ w))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5898 (setq ll (org-do-wrap words w)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5899 ll))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5900 (t (error "Cannot wrap this")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5901
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5902
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5903 (defun org-do-wrap (words width)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5904 "Creates lines of maximum width WIDTH (in characters) from word list WORDS."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5905 (let (lines line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5906 (while words
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5907 (setq line (pop words))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5908 (while (and words (< (+ (length line) (length (car words))) width))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5909 (setq line (concat line " " (pop words))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5910 (setq lines (push line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5911 (nreverse lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5912
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5913 ;; FIXME: I think I can make this more efficient
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5914 (defun org-split-string (string &optional separators)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5915 "Splits STRING into substrings at SEPARATORS.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5916 No empty strings are returned if there are matches at the beginning
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5917 and end of string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5918 (let ((rexp (or separators "[ \f\t\n\r\v]+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5919 (start 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5920 notfirst
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5921 (list nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5922 (while (and (string-match rexp string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5923 (if (and notfirst
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5924 (= start (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5925 (< start (length string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5926 (1+ start) start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5927 (< (match-beginning 0) (length string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5928 (setq notfirst t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5929 (or (eq (match-beginning 0) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5930 (and (eq (match-beginning 0) (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5931 (eq (match-beginning 0) start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5932 (setq list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5933 (cons (substring string start (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5934 list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5935 (setq start (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5936 (or (eq start (length string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5937 (setq list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5938 (cons (substring string start)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5939 list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5940 (nreverse list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5941
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5942 (defun org-table-add-invisible-to-vertical-lines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5943 "Add an `invisible' property to vertical lines of current table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5944 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5945 (let* ((beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5946 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5947 (end1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5948 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5949 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5950 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5951 (setq end1 (point-at-eol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5952 (if (looking-at org-table-dataline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5953 (while (re-search-forward "|" end1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5954 (add-text-properties (1- (point)) (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5955 '(invisible org-table)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5956 (while (re-search-forward "[+|]" end1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5957 (add-text-properties (1- (point)) (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5958 '(invisible org-table))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5959 (beginning-of-line 2)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5960
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5961 (defun org-table-toggle-vline-visibility (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5962 "Toggle the visibility of table vertical lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5963 The effect is immediate and on all tables in the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5964 With prefix ARG, make lines invisible when ARG if positive, make lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5965 visible when ARG is not positive"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5966 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5967 (let ((action (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5968 ((and arg (> (prefix-numeric-value arg) 0)) 'on)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5969 ((and arg (< (prefix-numeric-value arg) 1)) 'off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5970 (t (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5971 'off
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5972 'on)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5973 (if (eq action 'off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5974 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5975 (org-remove-from-invisibility-spec '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5976 (org-table-map-tables 'org-table-align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5977 (message "Vertical table lines visible")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5978 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5979 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5980 (org-add-to-invisibility-spec '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5981 (org-table-map-tables 'org-table-align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5982 (message "Vertical table lines invisible"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5983 (redraw-frame (selected-frame))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5984
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5985 (defun org-table-map-tables (function)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5986 "Apply FUNCTION to the start of all tables in the buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5987 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5988 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5989 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5990 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5991 (while (re-search-forward org-table-any-line-regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5992 (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5993 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5994 (if (looking-at org-table-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5995 (save-excursion (funcall function)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5996 (re-search-forward org-table-any-border-regexp nil 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5997
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5998 (defun org-table-sum ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5999 "Sum numbers in region of current table column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6000 The result will be displayed in the echo area, and will be available
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6001 as kill to be inserted with \\[yank].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6002
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6003 If there is an active region, it is interpreted as a rectangle and all
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6004 numbers in that rectangle will be summed. If there is no active
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6005 region and point is located in a table column, sum all numbers in that
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6006 column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6007
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6008 If at least on number looks like a time HH:MM or HH:MM:SS, all other
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6009 numbers are assumed to be times as well (in decimal hours) and the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6010 numbers are added as such."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6011 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6012 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6013 (let (beg end col (timecnt 0) diff h m s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6014 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6015 (setq beg (region-beginning) end (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6016 (setq col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6017 (goto-char (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6018 (unless (re-search-forward "^[ \t]*|[^-]" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6019 (error "No table data"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6020 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6021 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6022 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6023 (goto-char (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6024 (unless (re-search-backward "^[ \t]*|[^-]" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6025 (error "No table data"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6026 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6027 (skip-chars-forward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6028 (setq end (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6029 (let* ((l1 (progn (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6030 (+ (if (bolp) 1 0) (count-lines (point-min) (point)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6031 (l2 (progn (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6032 (+ (if (bolp) 1 0) (count-lines (point-min) (point)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6033 (items (if (= l1 l2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6034 (split-string (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6035 (split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6036 (mapconcat 'identity (extract-rectangle beg end) " "))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6037 (numbers (delq nil (mapcar 'org-table-get-number-for-summing
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6038 items)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6039 (res (apply '+ numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6040 (sres (if (= timecnt 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6041 (format "%g" res)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6042 (setq diff (* 3600 res)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6043 h (floor (/ diff 3600)) diff (mod diff 3600)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6044 m (floor (/ diff 60)) diff (mod diff 60)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6045 s diff)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6046 (format "%d:%02d:%02d" h m s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6047 (kill-new sres)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6048 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6049 (format "Sum of %d items: %-20s (\\[yank] will insert result into buffer)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6050 (length numbers) sres)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6051
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6052 (defun org-table-get-number-for-summing (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6053 (let (n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6054 (if (string-match "^ *|? *" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6055 (setq s (replace-match "" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6056 (if (string-match " *|? *$" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6057 (setq s (replace-match "" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6058 (setq n (string-to-number s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6059 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6060 ((and (string-match "0" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6061 (string-match "\\`[-+ \t0.edED]+\\'" s)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6062 ((string-match "\\`[ \t]+\\'" s) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6063 ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?\\'" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6064 (let ((h (string-to-number (or (match-string 1 s) "0")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6065 (m (string-to-number (or (match-string 2 s) "0")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6066 (s (string-to-number (or (match-string 4 s) "0"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6067 (if (boundp 'timecnt) (setq timecnt (1+ timecnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6068 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6069 ((equal n 0) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6070 (t n))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6071
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6072 (defvar org-table-current-formula nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6073 (defvar org-table-formula-history nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6074 (defun org-table-get-formula (current)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6075 (if (and current (not (equal "" org-table-current-formula)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6076 org-table-current-formula
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6077 (setq org-table-current-formula
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6078 (read-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6079 "Formula [last]: " "" 'org-table-formula-history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6080 org-table-current-formula))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6081
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6082 (defun org-this-word ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6083 ;; Get the current word
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6084 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6085 (let ((beg (progn (skip-chars-backward "^ \t\n") (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6086 (end (progn (skip-chars-forward "^ \t\n") (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6087 (buffer-substring-no-properties beg end))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6088
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6089 (defun org-table-eval-formula (&optional ndown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6090 "Replace the table field value at the cursor by the result of a calculation.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6091
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6092 This function makes use of Dave Gillespie's calc package, arguably the most
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6093 exciting program ever written for GNU Emacs. So you need to have calc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6094 installed in order to use this function.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6095
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6096 In a table, this command replaces the value in the current field with the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6097 result of a formula. While nowhere near the computation options of a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6098 spreadsheet program, this is still very useful. Note that there is no
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6099 automatic updating of a calculated field, nor will the field remember the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6100 formula. The command needs to be applied again after changing input
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6101 fields.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6102
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6103 When called, the command first prompts for a formula, which is read in the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6104 minibuffer. Previously entered formulae are available through the history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6105 list, and the last used formula is the default, reachable by simply
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6106 pressing RET.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6107
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6108 The formula can be any algebraic expression understood by the calc package.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6109 Before evaluation, variable substitution takes place: \"$\" is replaced by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6110 the field the cursor is currently in, and $1..$n reference the fields in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6111 the current row. Values from a *different* row can *not* be referenced
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6112 here, so the command supports only horizontal computing. The formula can
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6113 contain an optional printf format specifier after a semicolon, to reformat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6114 the result.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6115
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6116 A few examples for formulae:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6117 $1+$2 Sum of first and second field
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6118 $1+$2;%f.2 Same, and format result to two digits after dec.point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6119 exp($2)+exp($1) Math functions can be used
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6120 $;%f.1 Reformat current cell to 1 digit after dec.point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6121 ($3-32)*5/9 degrees F -> C conversion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6122
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6123 When called with a raw C-u prefix, the formula is applied to the current
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6124 field, and to the same same column in all following rows, until reaching a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6125 horizontal line or the end of the table. When the command is called with a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6126 numeric prefix argument (like M-3 or C-7 or C-u 24), the formula is applied
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6127 to the current row, and to the following n-1 rows (but not beyond a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6128 separator line)."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6129 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6130 (setq ndown (if (equal ndown '(4)) 10000 (prefix-numeric-value ndown)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6131 (require 'calc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6132 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6133 (let* (fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6134 (org-table-automatic-realign nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6135 (down (> ndown 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6136 (formula (org-table-get-formula nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6137 (n0 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6138 n form fmt x ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6139 (if (string-match ";" formula)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6140 (let ((tmp (org-split-string formula ";")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6141 (setq formula (car tmp) fmt (nth 1 tmp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6142 (while (> ndown 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6143 (setq fields (org-split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6144 (concat " " (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6145 (point-at-bol) (point-at-eol))) "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6146 (setq ndown (1- ndown))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6147 (setq form (copy-sequence formula))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6148 (while (string-match "\\$\\([0-9]+\\)?" form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6149 (setq n (if (match-beginning 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6150 (string-to-int (match-string 1 form))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6151 n0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6152 x (nth n fields))
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59596
diff changeset
6153 (unless x (error "Invalid field specifier \"%s\""
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6154 (match-string 0 form)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6155 (if (equal (string-to-number x) 0) (setq x "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6156 (setq form (replace-match x t t form)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6157 (setq ev (calc-eval (list form) 'num))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6158 (if (listp ev)
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59596
diff changeset
6159 (error "Invalid expression: %s (%s at %d)" form (nth 1 ev) (car ev)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6160 (org-table-blank-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6161 (if fmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6162 (insert (format fmt (string-to-number ev)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6163 (insert ev))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6164 (if (and down (> ndown 0) (looking-at ".*\n[ \t]*|[^-]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6165 (call-interactively 'org-return)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6166 (setq ndown 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6167 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6168
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6169 ;;; The orgtbl minor mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6170
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6171 ;; Define a minor mode which can be used in other modes in order to
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6172 ;; integrate the org-mode table editor.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6173
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6174 ;; This is really a hack, because the org-mode table editor uses several
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6175 ;; keys which normally belong to the major mode, for example the TAB and
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6176 ;; RET keys. Here is how it works: The minor mode defines all the keys
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6177 ;; necessary to operate the table editor, but wraps the commands into a
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6178 ;; function which tests if the cursor is currently inside a table. If that
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6179 ;; is the case, the table editor command is executed. However, when any of
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6180 ;; those keys is used outside a table, the function uses `key-binding' to
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6181 ;; look up if the key has an associated command in another currently active
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6182 ;; keymap (minor modes, major mode, global), and executes that command.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6183 ;; There might be problems if any of the keys used by the table editor is
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6184 ;; otherwise used as a prefix key.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6185
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6186 ;; Another challenge is that the key binding for TAB can be tab or \C-i,
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6187 ;; likewise the binding for RET can be return or \C-m. Orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6188 ;; addresses this by checking explicitly for both bindings.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6189
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6190 ;; The optimized version (see variable `orgtbl-optimized') takes over
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6191 ;; all keys which are bound to `self-insert-command' in the *global map*.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6192 ;; Some modes bind other commands to simple characters, for example
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6193 ;; AUCTeX binds the double quote to `Tex-insert-quote'. With orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6194 ;; active, this binding is ignored inside tables and replaced with a
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6195 ;; modified self-insert.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6196
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6197 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6198 "Non-nil means, use the optimized table editor version for orgtbl-mode.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6199 In the optimized version, the table editor takes over all simple keys that
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6200 normally just insert a character. In tables, the characters are inserted
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6201 in a way to minimize disturbing the table structure (i.e. in overwrite mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6202 for empty fields). Outside tables, the correct binding of the keys is
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6203 restored.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6204
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6205 The default for this option is t if the optimized version is also used in
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6206 Org-mode. See the variable `org-enable-table-editor' for details. Changing
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6207 this variable requires a restart of Emacs to become effective."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6208 :group 'org-table
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6209 :type 'boolean)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6210
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6211 (defvar orgtbl-mode nil
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6212 "Variable controlling orgtbl-mode, a minor mode enabling the org-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6213 table editor iin arbitrary modes.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6214 (make-variable-buffer-local 'orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6215
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6216 (defvar orgtbl-mode-map (make-sparse-keymap)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6217 "Keymap for orgtbl-mode.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6218
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6219 ;;;###autoload
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6220 (defun turn-on-orgtbl ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6221 "Unconditionally turn on orgtbl-mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6222 (orgtbl-mode 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6223
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6224 ;;;###autoload
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6225 (defun orgtbl-mode (&optional arg)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6226 "The org-mode table editor as a minor mode for use in other modes."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6227 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6228 (setq orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6229 (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6230 (if orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6231 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6232 (set (make-local-variable (quote org-table-may-need-update)) t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6233 (make-local-hook (quote before-change-functions))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6234 (add-hook 'before-change-functions 'org-before-change-function
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6235 nil 'local)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6236 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6237 auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6238 (set (make-local-variable 'auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6239 (if auto-fill-inhibit-regexp
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6240 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6241 "[ \t]*|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6242 (easy-menu-add orgtbl-mode-menu)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6243 (run-hooks (quote orgtbl-mode-hook)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6244 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6245 (remove-hook 'before-change-functions 'org-before-change-function t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6246 (easy-menu-remove orgtbl-mode-menu)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6247 (force-mode-line-update 'all)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6248
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6249 ;; Install it as a minor mode.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6250 (put 'orgtbl-mode :included t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6251 (put 'orgtbl-mode :menu-tag "Org Table Mode")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6252 (add-minor-mode 'orgtbl-mode " OrgTbl" orgtbl-mode-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6253
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6254 (defun orgtbl-make-binding (fun &rest keys)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6255 "Create a function for binding in the table minor mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6256 (list 'lambda '(arg) '(interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6257 (list 'if
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6258 '(org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6259 (list 'call-interactively (list 'quote fun))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6260 (list 'let '(orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6261 (list 'call-interactively
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6262 (append '(or)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6263 (mapcar (lambda (k)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6264 (list 'key-binding k))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6265 keys)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6266 '('orgtbl-error)))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6267
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6268 (defun orgtbl-error ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6269 "Error when there is no default binding for a table key."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6270 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6271 (error "This key is has no function outside tables"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6272
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6273 ;; Keybindings for the minor mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6274 (let ((bindings
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6275 '(([(meta shift left)] org-table-delete-column)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6276 ([(meta left)] org-table-move-column-left)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6277 ([(meta right)] org-table-move-column-right)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6278 ([(meta shift right)] org-table-insert-column)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6279 ([(meta shift up)] org-table-kill-row)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6280 ([(meta shift down)] org-table-insert-row)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6281 ([(meta up)] org-table-move-row-up)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6282 ([(meta down)] org-table-move-row-down)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6283 ("\C-c\C-w" org-table-cut-region)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6284 ("\C-c\M-w" org-table-copy-region)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6285 ("\C-c\C-y" org-table-paste-rectangle)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6286 ("\C-c-" org-table-insert-hline)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6287 ([(shift tab)] org-table-previous-field)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6288 ("\C-c\C-c" org-table-align)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6289 ([(return)] org-table-next-row)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6290 ([(shift return)] org-table-copy-down)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6291 ([(meta return)] org-table-wrap-region)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6292 ("\C-c\C-q" org-table-wrap-region)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6293 ("\C-c?" org-table-current-column)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6294 ("\C-c " org-table-blank-field)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6295 ("\C-c+" org-table-sum)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6296 ("\C-c|" org-table-toggle-vline-visibility)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6297 ("\C-c=" org-table-eval-formula)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6298 elt key fun cmd)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6299 (while (setq elt (pop bindings))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6300 (setq key (car elt)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6301 fun (nth 1 elt)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6302 cmd (orgtbl-make-binding fun key))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6303 (define-key orgtbl-mode-map key cmd)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6304
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6305 ;; Special treatment needed for TAB and RET
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6306 ;(define-key orgtbl-mode-map [(return)]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6307 ; (orgtbl-make-binding 'org-table-next-row [(return)] "\C-m"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6308 ;(define-key orgtbl-mode-map "\C-m"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6309 ; (orgtbl-make-binding 'org-table-next-row "\C-m" [(return)]))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6310 ;(define-key orgtbl-mode-map [(tab)]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6311 ; (orgtbl-make-binding 'org-table-next-field [(tab)] "\C-i"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6312 ;(define-key orgtbl-mode-map "\C-i"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6313 ; (orgtbl-make-binding 'org-table-next-field "\C-i" [(tab)]))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6314
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6315 (define-key orgtbl-mode-map [(return)]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6316 (orgtbl-make-binding 'orgtbl-ret [(return)] "\C-m"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6317 (define-key orgtbl-mode-map "\C-m"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6318 (orgtbl-make-binding 'orgtbl-ret "\C-m" [(return)]))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6319 (define-key orgtbl-mode-map [(tab)]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6320 (orgtbl-make-binding 'orgtbl-tab [(tab)] "\C-i"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6321 (define-key orgtbl-mode-map "\C-i"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6322 (orgtbl-make-binding 'orgtbl-tab "\C-i" [(tab)]))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6323
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6324 (when orgtbl-optimized
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6325 ;; If the user wants maximum table support, we need to hijack
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6326 ;; some standard editing functions
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6327 (substitute-key-definition 'self-insert-command 'orgtbl-self-insert-command
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6328 orgtbl-mode-map global-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6329 (substitute-key-definition 'delete-char 'orgtbl-delete-char
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6330 orgtbl-mode-map global-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6331 (substitute-key-definition 'delete-backward-char 'orgtbl-delete-backward-char
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6332 orgtbl-mode-map global-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6333 (define-key org-mode-map "|" 'self-insert-command))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6334
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6335 (defun orgtbl-tab ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6336 "Justification and field motion for orgtbl-mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6337 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6338 (org-table-justify-field-maybe)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6339 (org-table-next-field))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6340
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6341 (defun orgtbl-ret ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6342 "Justification and field motion for orgtbl-mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6343 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6344 (org-table-justify-field-maybe)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6345 (org-table-next-row))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6346
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6347 (defun orgtbl-self-insert-command (N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6348 "Like `self-insert-command', use overwrite-mode for whitespace in tables.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6349 If the cursor is in a table looking at whitespace, the whitespace is
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6350 overwritten, and the table is not marked as requiring realignment."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6351 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6352 (if (and (org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6353 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6354 (looking-at "[^|\n]* +|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6355 (let (org-table-may-need-update (pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6356 (goto-char (1- (match-end 0)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6357 (delete-backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6358 (goto-char (match-beginning 0))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6359 (self-insert-command N))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6360 (setq org-table-may-need-update t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6361 (let (orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6362 (call-interactively (key-binding (vector last-input-event))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6363
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6364 (defun orgtbl-delete-backward-char (N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6365 "Like `delete-backward-char', insert whitespace at field end in tables.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6366 When deleting backwards, in tables this function will insert whitespace in
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6367 front of the next \"|\" separator, to keep the table aligned. The table will
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6368 still be marked for re-alignment, because a narrow field may lead to a
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6369 reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6370 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6371 (if (and (org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6372 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6373 (looking-at ".*?|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6374 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6375 (backward-delete-char N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6376 (skip-chars-forward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6377 (insert " ")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6378 (goto-char (1- pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6379 (message "%s" last-input-event) (sit-for 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6380 (delete-backward-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6381
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6382 (defun orgtbl-delete-char (N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6383 "Like `delete-char', but insert whitespace at field end in tables.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6384 When deleting characters, in tables this function will insert whitespace in
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6385 front of the next \"|\" separator, to keep the table aligned. The table
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6386 will still be marked for re-alignment, because a narrow field may lead to
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6387 a reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6388 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6389 (if (and (org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6390 (eq N 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6391 (if (looking-at ".*?|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6392 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6393 (replace-match (concat
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6394 (substring (match-string 0) 1 -1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6395 " |"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6396 (goto-char pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6397 (delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6398
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6399 (easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6400 '("Tbl"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6401 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6402 ["Next field" org-cycle :active (org-at-table-p) :keys "TAB"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6403 ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6404 ["Next row" org-return :active (org-at-table-p) :keys "RET"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6405 "--"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6406 ["Blank field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6407 ["Copy field from above"
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6408 org-table-copy-down :active (org-at-table-p) :keys "S-RET"]
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6409 "--"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6410 ("Column"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6411 ["Move column left" org-metaleft :active (org-at-table-p) :keys "M-<left>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6412 ["Move column right" org-metaright :active (org-at-table-p) :keys "M-<right>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6413 ["Delete column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6414 ["Insert column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"])
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6415 ("Row"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6416 ["Move row up" org-metaup :active (org-at-table-p) :keys "M-<up>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6417 ["Move row down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6418 ["Delete row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6419 ["Insert row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6420 "--"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6421 ["Insert hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6422 ("Rectangle"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6423 ["Copy rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6424 ["Cut rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6425 ["Paste rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6426 ["Fill rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"])
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6427 "--"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6428 ["Which column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6429 ["Sum column/rectangle" org-table-sum
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6430 :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6431 ["Eval formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6432 ))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6433
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6434 ;;; Exporting
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6435
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6436 (defconst org-level-max 20)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6437
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6438 (defun org-export-find-first-heading-line (list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6439 "Remove all lines from LIST which are before the first headline."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6440 (let ((orig-list list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6441 (re (concat "^" outline-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6442 (while (and list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6443 (not (string-match re (car list))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6444 (pop list))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6445 (or list orig-list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6446
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6447 (defun org-skip-comments (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6448 "Skip lines starting with \"#\" and subtrees starting with COMMENT."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6449 (let ((re1 (concat "^\\(\\*+\\)[ \t]+" org-comment-string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6450 (re2 "^\\(\\*+\\)[ \t\n\r]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6451 rtn line level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6452 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6453 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6454 ((and (string-match re1 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6455 (setq level (- (match-end 1) (match-beginning 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6456 ;; Beginning of a COMMENT subtree. Skip it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6457 (while (and (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6458 (or (not (string-match re2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6459 (> (- (match-end 1) (match-beginning 1)) level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6460 (setq lines (cons line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6461 ((string-match "^#" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6462 ;; an ordinary comment line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6463 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6464 (t (setq rtn (cons line rtn)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6465 (nreverse rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6466
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6467 ;; ASCII
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6468
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6469 (defconst org-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6470 "Characters for underlining headings in ASCII export.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6471
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6472 (defconst org-html-entities
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6473 '(("nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6474 ("iexcl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6475 ("cent")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6476 ("pound")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6477 ("curren")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6478 ("yen")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6479 ("brvbar")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6480 ("sect")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6481 ("uml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6482 ("copy")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6483 ("ordf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6484 ("laquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6485 ("not")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6486 ("shy")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6487 ("reg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6488 ("macr")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6489 ("deg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6490 ("plusmn")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6491 ("sup2")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6492 ("sup3")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6493 ("acute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6494 ("micro")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6495 ("para")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6496 ("middot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6497 ("odot"."o")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6498 ("star"."*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6499 ("cedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6500 ("sup1")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6501 ("ordm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6502 ("raquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6503 ("frac14")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6504 ("frac12")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6505 ("frac34")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6506 ("iquest")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6507 ("Agrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6508 ("Aacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6509 ("Acirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6510 ("Atilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6511 ("Auml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6512 ("Aring") ("AA"."&Aring;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6513 ("AElig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6514 ("Ccedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6515 ("Egrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6516 ("Eacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6517 ("Ecirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6518 ("Euml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6519 ("Igrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6520 ("Iacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6521 ("Icirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6522 ("Iuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6523 ("ETH")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6524 ("Ntilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6525 ("Ograve")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6526 ("Oacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6527 ("Ocirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6528 ("Otilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6529 ("Ouml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6530 ("times")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6531 ("Oslash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6532 ("Ugrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6533 ("Uacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6534 ("Ucirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6535 ("Uuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6536 ("Yacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6537 ("THORN")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6538 ("szlig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6539 ("agrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6540 ("aacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6541 ("acirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6542 ("atilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6543 ("auml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6544 ("aring")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6545 ("aelig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6546 ("ccedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6547 ("egrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6548 ("eacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6549 ("ecirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6550 ("euml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6551 ("igrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6552 ("iacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6553 ("icirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6554 ("iuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6555 ("eth")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6556 ("ntilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6557 ("ograve")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6558 ("oacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6559 ("ocirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6560 ("otilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6561 ("ouml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6562 ("divide")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6563 ("oslash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6564 ("ugrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6565 ("uacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6566 ("ucirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6567 ("uuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6568 ("yacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6569 ("thorn")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6570 ("yuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6571 ("fnof")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6572 ("Alpha")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6573 ("Beta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6574 ("Gamma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6575 ("Delta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6576 ("Epsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6577 ("Zeta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6578 ("Eta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6579 ("Theta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6580 ("Iota")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6581 ("Kappa")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6582 ("Lambda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6583 ("Mu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6584 ("Nu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6585 ("Xi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6586 ("Omicron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6587 ("Pi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6588 ("Rho")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6589 ("Sigma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6590 ("Tau")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6591 ("Upsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6592 ("Phi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6593 ("Chi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6594 ("Psi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6595 ("Omega")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6596 ("alpha")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6597 ("beta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6598 ("gamma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6599 ("delta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6600 ("epsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6601 ("varepsilon"."&epsilon;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6602 ("zeta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6603 ("eta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6604 ("theta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6605 ("iota")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6606 ("kappa")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6607 ("lambda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6608 ("mu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6609 ("nu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6610 ("xi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6611 ("omicron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6612 ("pi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6613 ("rho")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6614 ("sigmaf") ("varsigma"."&sigmaf;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6615 ("sigma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6616 ("tau")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6617 ("upsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6618 ("phi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6619 ("chi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6620 ("psi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6621 ("omega")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6622 ("thetasym") ("vartheta"."&thetasym;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6623 ("upsih")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6624 ("piv")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6625 ("bull") ("bullet"."&bull;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6626 ("hellip") ("dots"."&hellip;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6627 ("prime")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6628 ("Prime")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6629 ("oline")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6630 ("frasl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6631 ("weierp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6632 ("image")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6633 ("real")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6634 ("trade")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6635 ("alefsym")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6636 ("larr") ("leftarrow"."&larr;") ("gets"."&larr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6637 ("uarr") ("uparrow"."&uarr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6638 ("rarr") ("to"."&rarr;") ("rightarrow"."&rarr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6639 ("darr")("downarrow"."&darr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6640 ("harr") ("leftrightarrow"."&harr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6641 ("crarr") ("hookleftarrow"."&crarr;") ; has round hook, not quite CR
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6642 ("lArr") ("Leftarrow"."&lArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6643 ("uArr") ("Uparrow"."&uArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6644 ("rArr") ("Rightarrow"."&rArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6645 ("dArr") ("Downarrow"."&dArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6646 ("hArr") ("Leftrightarrow"."&hArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6647 ("forall")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6648 ("part") ("partial"."&part;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6649 ("exist") ("exists"."&exist;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6650 ("empty") ("emptyset"."&empty;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6651 ("nabla")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6652 ("isin") ("in"."&isin;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6653 ("notin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6654 ("ni")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6655 ("prod")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6656 ("sum")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6657 ("minus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6658 ("lowast") ("ast"."&lowast;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6659 ("radic")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6660 ("prop") ("proptp"."&prop;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6661 ("infin") ("infty"."&infin;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6662 ("ang") ("angle"."&ang;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6663 ("and") ("vee"."&and;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6664 ("or") ("wedge"."&or;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6665 ("cap")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6666 ("cup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6667 ("int")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6668 ("there4")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6669 ("sim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6670 ("cong") ("simeq"."&cong;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6671 ("asymp")("approx"."&asymp;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6672 ("ne") ("neq"."&ne;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6673 ("equiv")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6674 ("le")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6675 ("ge")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6676 ("sub") ("subset"."&sub;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6677 ("sup") ("supset"."&sup;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6678 ("nsub")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6679 ("sube")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6680 ("supe")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6681 ("oplus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6682 ("otimes")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6683 ("perp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6684 ("sdot") ("cdot"."&sdot;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6685 ("lceil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6686 ("rceil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6687 ("lfloor")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6688 ("rfloor")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6689 ("lang")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6690 ("rang")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6691 ("loz") ("Diamond"."&loz;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6692 ("spades") ("spadesuit"."&spades;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6693 ("clubs") ("clubsuit"."&clubs;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6694 ("hearts") ("diamondsuit"."&hearts;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6695 ("diams") ("diamondsuit"."&diams;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6696 ("quot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6697 ("amp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6698 ("lt")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6699 ("gt")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6700 ("OElig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6701 ("oelig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6702 ("Scaron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6703 ("scaron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6704 ("Yuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6705 ("circ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6706 ("tilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6707 ("ensp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6708 ("emsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6709 ("thinsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6710 ("zwnj")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6711 ("zwj")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6712 ("lrm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6713 ("rlm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6714 ("ndash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6715 ("mdash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6716 ("lsquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6717 ("rsquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6718 ("sbquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6719 ("ldquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6720 ("rdquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6721 ("bdquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6722 ("dagger")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6723 ("Dagger")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6724 ("permil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6725 ("lsaquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6726 ("rsaquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6727 ("euro")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6728
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6729 ("arccos"."arccos")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6730 ("arcsin"."arcsin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6731 ("arctan"."arctan")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6732 ("arg"."arg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6733 ("cos"."cos")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6734 ("cosh"."cosh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6735 ("cot"."cot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6736 ("coth"."coth")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6737 ("csc"."csc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6738 ("deg"."deg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6739 ("det"."det")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6740 ("dim"."dim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6741 ("exp"."exp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6742 ("gcd"."gcd")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6743 ("hom"."hom")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6744 ("inf"."inf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6745 ("ker"."ker")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6746 ("lg"."lg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6747 ("lim"."lim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6748 ("liminf"."liminf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6749 ("limsup"."limsup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6750 ("ln"."ln")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6751 ("log"."log")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6752 ("max"."max")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6753 ("min"."min")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6754 ("Pr"."Pr")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6755 ("sec"."sec")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6756 ("sin"."sin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6757 ("sinh"."sinh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6758 ("sup"."sup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6759 ("tan"."tan")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6760 ("tanh"."tanh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6761 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6762 "Entities for TeX->HTML translation.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6763 Entries can be like (\"ent\"), in which case \"\\ent\" will be translated to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6764 \"&ent;\". An entry can also be a dotted pair like (\"ent\".\"&other;\").
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6765 In that case, \"\\ent\" will be translated to \"&other;\".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6766 The list contains HTML entities for Latin-1, Greek and other symbols.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6767 It is supplemented by a number of commonly used TeX macros with appropriate
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6768 translations.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6769
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6770 (defun org-export-as-ascii (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6771 "Export the outline as a pretty ASCII file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6772 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6773 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6774 underlined headlines. The default is 3."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6775 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6776 (setq-default org-todo-line-regexp org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6777 (let* ((region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6778 (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6779 (if (org-region-active-p) (region-beginning) (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6780 (if (org-region-active-p) (region-end) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6781 (lines (org-export-find-first-heading-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6782 (org-skip-comments (org-split-string region "[\r\n]"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6783 (org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6784 (level 0) line txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6785 (umax nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6786 (case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6787 (filename (concat (file-name-sans-extension (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6788 ".txt"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6789 (buffer (find-file-noselect filename))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6790 (levels-open (make-vector org-level-max nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6791 (date (format-time-string "%Y/%m/%d" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6792 (time (format-time-string "%X" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6793 (author user-full-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6794 (title (buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6795 (options nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6796 (email user-mail-address)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6797 (language org-export-default-language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6798 (text nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6799 (last-level 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6800 (todo nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6801 (lang-words nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6802
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6803 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6804
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6805 (find-file-noselect filename)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6806
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6807 ;; Search for the export key lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6808 (org-parse-key-lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6809
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6810 (setq lang-words (or (assoc language org-export-language-setup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6811 (assoc "en" org-export-language-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6812 (if org-export-ascii-show-new-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6813 (switch-to-buffer-other-window buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6814 (set-buffer buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6815 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6816 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6817 (if options (org-parse-export-options options))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6818 (setq umax (if arg (prefix-numeric-value arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6819 org-export-headline-levels))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6820
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6821 ;; File header
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6822 (if title (org-insert-centered title ?=))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6823 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6824 (if (or author email)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6825 (insert (concat (nth 1 lang-words) ": " (or author "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6826 (if email (concat " <" email ">") "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6827 "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6828 (if (and date time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6829 (insert (concat (nth 2 lang-words) ": " date " " time "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6830 (if text (insert (concat (org-html-expand-for-ascii text) "\n\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6831
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6832 (insert "\n\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6833
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6834 (if org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6835 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6836 (insert (nth 3 lang-words) "\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6837 (make-string (length (nth 3 lang-words)) ?=) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6838 (mapcar '(lambda (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6839 (if (string-match org-todo-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6840 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6841 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6842 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6843 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6844 txt (match-string 3 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6845 todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6846 (or (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6847 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6848 org-done-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6849 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6850 (and (= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6851 (org-search-todo-below
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6852 line lines level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6853 (setq txt (org-html-expand-for-ascii txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6854
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6855 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6856 (setq txt (concat (org-section-number level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6857 " " txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6858 (if (<= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6859 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6860 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6861 (make-string (* (1- level) 4) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6862 (format (if todo "%s (*)\n" "%s\n") txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6863 (setq last-level level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6864 ))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6865 lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6866
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6867 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6868 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6869 ;; Remove the quoted HTML tags.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6870 (setq line (org-html-expand-for-ascii line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6871 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6872 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6873 ;; a Headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6874 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6875 txt (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6876 (org-ascii-level-start level txt umax))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6877 (t (insert line "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6878 (normal-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6879 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6880 (goto-char (point-min))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6881
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6882 (defun org-search-todo-below (line lines level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6883 "Search the subtree below LINE for any TODO entries."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6884 (let ((rest (cdr (memq line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6885 (re org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6886 line lv todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6887 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6888 (while (setq line (pop rest))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6889 (if (string-match re line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6890 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6891 (setq lv (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6892 todo (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6893 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6894 org-done-string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6895 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6896 (if (<= lv level) (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6897 (if todo (throw 'exit t))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6898
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6899 ;; FIXME: Try to handle <b> and <i> as faces via text properties.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6900 ;; FIXME: Can I implement *bold*,/italic/ and _underline_ for AXCII export?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6901 (defun org-html-expand-for-ascii (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6902 "Handle quoted HTML for ASCII export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6903 (if org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6904 (while (string-match "@<[^<>\n]*>" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6905 ;; We just remove the tags for now.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6906 (setq line (replace-match "" nil nil line))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6907 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6908
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6909 (defun org-insert-centered (s &optional underline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6910 "Insert the string S centered and underline it with character UNDERLINE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6911 (let ((ind (max (/ (- 80 (length s)) 2) 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6912 (insert (make-string ind ?\ ) s "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6913 (if underline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6914 (insert (make-string ind ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6915 (make-string (length s) underline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6916 "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6917
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6918 (defun org-ascii-level-start (level title umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6919 "Insert a new level in ASCII export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6920 (let (char)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6921 (if (> level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6922 (insert (make-string (* 2 (- level umax 1)) ?\ ) "* " title "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6923 (if (or (not (equal (char-before) ?\n))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6924 (not (equal (char-before (1- (point))) ?\n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6925 (insert "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6926 (setq char (nth (- umax level) (reverse org-ascii-underline)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6927 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6928 (setq title (concat (org-section-number level) " " title)))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6929 (insert title "\n" (make-string (string-width title) char) "\n"))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6930
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6931 (defun org-export-copy-visible (&optional arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6932 "Copy the visible part of the buffer to another buffer, for printing.
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6933 Also removes the first line of the buffer it is specifies a mode,
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6934 and all options lines."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6935 (interactive "P")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6936 (let* ((filename (concat (file-name-sans-extension (buffer-file-name))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6937 ".txt"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6938 (buffer (find-file-noselect filename))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6939 (ore (concat
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6940 (org-make-options-regexp
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6941 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP"
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6942 "TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6943 (if org-noutline-p "\\(\n\\|$\\)" "")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6944 s e)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6945 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6946 (set-buffer buffer)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6947 (erase-buffer)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6948 (text-mode))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6949 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6950 (setq s (goto-char (point-min)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6951 (while (not (= (point) (point-max)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6952 (goto-char (org-find-invisible))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6953 (append-to-buffer buffer s (point))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6954 (setq s (goto-char (org-find-visible)))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6955 (switch-to-buffer-other-window buffer)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6956 (newline)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6957 (goto-char (point-min))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6958 (if (looking-at ".*-\\*- mode:.*\n")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6959 (replace-match ""))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6960 (while (re-search-forward ore nil t)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6961 (replace-match ""))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6962 (goto-char (point-min))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6963
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6964 (defun org-find-visible ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6965 (if (featurep 'noutline)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6966 (let ((s (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6967 (while (and (not (= (point-max) (setq s (next-overlay-change s))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6968 (get-char-property s 'invisible)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6969 s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6970 (skip-chars-forward "^\n")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6971 (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6972 (defun org-find-invisible ()
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6973 (if (featurep 'noutline)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6974 (let ((s (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6975 (while (and (not (= (point-max) (setq s (next-overlay-change s))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6976 (not (get-char-property s 'invisible))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6977 s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6978 (skip-chars-forward "^\r")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
6979 (point)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6980
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6981 ;; HTML
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6982
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6983 (defun org-get-current-options ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6984 "Return a string with current options as keyword options.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6985 Does include HTML export options as well as TODO and CATEGORY stuff."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6986 (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6987 "#+TITLE: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6988 #+AUTHOR: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6989 #+EMAIL: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6990 #+LANGUAGE: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6991 #+TEXT: Some descriptive text to be emitted. Several lines OK.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6992 #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s *:%s TeX:%s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6993 #+CATEGORY: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6994 #+SEQ_TODO: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6995 #+TYP_TODO: %s
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6996 #+STARTUP: %s %s
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6997 "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6998 (buffer-name) (user-full-name) user-mail-address org-export-default-language
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6999 org-export-headline-levels
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7000 org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7001 org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7002 org-export-preserve-breaks
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7003 org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7004 org-export-with-fixed-width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7005 org-export-with-tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7006 org-export-with-sub-superscripts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7007 org-export-with-emphasize
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7008 org-export-with-TeX-macros
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7009 (file-name-nondirectory (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7010 (if (equal org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7011 (mapconcat 'identity org-todo-keywords " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7012 "TODO FEEDBACK VERIFY DONE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7013 (if (equal org-todo-interpretation 'type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7014 (mapconcat 'identity org-todo-keywords " ")
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7015 "Me Jason Marie DONE")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7016 (if org-startup-folded "fold" "nofold")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7017 (if org-startup-with-deadline-check "dlcheck" "nodlcheck")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7018 ))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7019
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7020 (defun org-insert-export-options-template ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7021 "Insert into the buffer a template with information for exporting."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7022 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7023 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7024 (let ((s (org-get-current-options)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7025 (and (string-match "#\\+CATEGORY" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7026 (setq s (substring s 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7027 (insert s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7028
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7029 (defun org-toggle-fixed-width-section (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7030 "Toggle the fixed-width indicator at the beginning of lines in the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7031 If there is no active region, only acts on the current line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7032 If the first non-white character in the first line of the region is a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7033 vertical bar \"|\", then the command removes the bar from all lines in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7034 the region. If the first character is not a bar, the command adds a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7035 bar to all lines, in the column given by the beginning of the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7036
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7037 If there is a numerical prefix ARG, create ARG new lines starting with \"|\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7038 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7039 (let* ((cc 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7040 (regionp (org-region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7041 (beg (if regionp (region-beginning) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7042 (end (if regionp (region-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7043 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7044 (re "[ \t]*\\(:\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7045 off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7046 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7047 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7048 (setq cc (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7049 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7050 (setq off (looking-at re))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7051 (while (> nlines 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7052 (setq nlines (1- nlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7053 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7054 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7055 (arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7056 (move-to-column cc t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7057 (insert ":\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7058 (forward-line -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7059 ((and off (looking-at re))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7060 (replace-match "" t t nil 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7061 ((not off) (move-to-column cc t) (insert ":")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7062 (forward-line 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7063
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7064 (defun org-export-as-html-and-open (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7065 "Export the outline as HTML and immediately open it with a browser.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7066 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7067 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7068 headlines. The default is 3. Lower levels will become bulleted lists."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7069 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7070 (org-export-as-html arg 'hidden)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7071 (org-open-file (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7072
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7073 (defun org-export-as-html-batch ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7074 "Call org-export-as-html, may be used in batch processing as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7075 emacs --batch
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7076 --load=$HOME/lib/emacs/org.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7077 --eval \"(setq org-export-headline-levels 2)\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7078 --visit=MyFile --funcall org-export-as-html-batch"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7079 (org-export-as-html org-export-headline-levels 'hidden))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7080
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7081 (defun org-export-as-html (arg &optional hidden)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7082 "Export the outline as a pretty HTML file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7083 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7084 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7085 headlines. The default is 3. Lower levels will become bulleted lists."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7086 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7087 (setq-default org-todo-line-regexp org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7088 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7089 (setq-default org-done-string org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7090 (let* ((region-p (org-region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7091 (region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7092 (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7093 (if region-p (region-beginning) (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7094 (if region-p (region-end) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7095 (all_lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7096 (org-skip-comments (org-split-string region "[\r\n]")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7097 (lines (org-export-find-first-heading-line all_lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7098 (level 0) (line "") (origline "") txt todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7099 (last-level 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7100 (umax nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7101 (filename (concat (file-name-sans-extension (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7102 ".html"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7103 (buffer (find-file-noselect filename))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7104 (levels-open (make-vector org-level-max nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7105 (date (format-time-string "%Y/%m/%d" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7106 (time (format-time-string "%X" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7107 (author user-full-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7108 (title (buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7109 (options nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7110 (email user-mail-address)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7111 (language org-export-default-language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7112 (text nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7113 (lang-words nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7114 (head-count 0) cnt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7115 table-open type
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7116 table-buffer table-orig-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7117 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7118 (message "Exporting...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7119
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7120 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7121
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7122 ;; Search for the export key lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7123 (org-parse-key-lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7124 (setq lang-words (or (assoc language org-export-language-setup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7125 (assoc "en" org-export-language-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7126
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7127 ;; Switch to the output buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7128 (if (or hidden (not org-export-html-show-new-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7129 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7130 (switch-to-buffer-other-window buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7131 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7132 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7133 (let ((case-fold-search nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7134 (if options (org-parse-export-options options))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7135 (setq umax (if arg (prefix-numeric-value arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7136 org-export-headline-levels))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7137
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7138 ;; File header
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7139 (insert (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7140 "<html lang=\"%s\"><head>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7141 <title>%s</title>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7142 <meta http-equiv=\"Content-Type\" content=\"text/html\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7143 <meta name=generator content=\"Org-mode\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7144 <meta name=generated content=\"%s %s\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7145 <meta name=author content=\"%s\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7146 </head><body>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7147 "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7148 language (org-html-expand title) date time author))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7149 (if title (insert (concat "<H1 align=\"center\">"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7150 (org-html-expand title) "</H1>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7151 (if author (insert (concat (nth 1 lang-words) ": " author "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7152 (if email (insert (concat "<a href=\"mailto:" email "\">&lt;"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7153 email "&gt;</a>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7154 (if (or author email) (insert "<br>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7155 (if (and date time) (insert (concat (nth 2 lang-words) ": "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7156 date " " time "<br>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7157 (if text (insert (concat "<p>\n" (org-html-expand text))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7158 (if org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7159 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7160 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7161 (insert "<ul>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7162 (mapcar '(lambda (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7163 (if (string-match org-todo-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7164 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7165 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7166 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7167 txt (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7168 (org-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7169 (match-string 3 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7170 todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7171 (or (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7172 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7173 org-done-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7174 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7175 (and (= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7176 (org-search-todo-below
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7177 line lines level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7178 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7179 (setq txt (concat (org-section-number level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7180 " " txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7181 (if (<= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7182 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7183 (setq head-count (+ head-count 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7184 (if (> level last-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7185 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7186 (setq cnt (- level last-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7187 (while (>= (setq cnt (1- cnt)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7188 (insert "<ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7189 (insert "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7190 (if (< level last-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7191 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7192 (setq cnt (- last-level level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7193 (while (>= (setq cnt (1- cnt)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7194 (insert "</ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7195 (insert "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7196 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7197 (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7198 (if todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7199 "<li><a href=\"#sec-%d\"><span style='color:red'>%s</span></a></li>\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7200 "<li><a href=\"#sec-%d\">%s</a></li>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7201 head-count txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7202 (setq last-level level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7203 ))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7204 lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7205 (while (> last-level 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7206 (setq last-level (1- last-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7207 (insert "</ul>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7208 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7209 (setq head-count 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7210 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7211
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7212 (while (setq line (pop lines) origline line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7213 ;; replace "<" and ">" by "&lt;" and "&gt;"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7214 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7215 (setq line (org-html-expand line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7216
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7217 ;; Verbatim lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7218 (if (and org-export-with-fixed-width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7219 (string-match "^[ \t]*:\\(.*\\)" line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7220 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7221 (let ((l (match-string 1 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7222 (while (string-match " " l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7223 (setq l (replace-match "&nbsp;" t t l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7224 (insert "\n<span style='font-family:Courier'>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7225 l "</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7226 (if (and lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7227 (not (string-match "^[ \t]+\\(:.*\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7228 (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7229 "<br>\n" "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7230
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7231 (when (string-match org-link-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7232 (setq type (match-string 1 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7233 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7234 ((member type '("http" "https" "ftp" "mailto" "news"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7235 ;; standard URL
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7236 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7237 "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7238 nil nil line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7239 ((string= type "file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7240 ;; FILE link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7241
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7242 (let* ((filename (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7243 (file-is-image-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7244 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7245 (string-match (org-image-file-name-regexp) filename))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7246 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7247 (if (and org-export-html-inline-images
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7248 file-is-image-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7249 "<img src=\"\\2\"/>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7250 "<a href=\"\\2\">\\1:\\2</a>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7251 nil nil line))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7252
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7253 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7254 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7255 "<i>&lt;\\1:\\2&gt;</i>" nil nil line)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7256
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7257 ;; TODO items
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7258 (if (and (string-match org-todo-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7259 (match-beginning 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7260 (if (equal (match-string 2 line) org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7261 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7262 "<span style='color:green'>\\2</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7263 nil nil line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7264 (setq line (replace-match "<span style='color:red'>\\2</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7265 nil nil line 2))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7266
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7267 ;; DEADLINES
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7268 (if (string-match org-deadline-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7269 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7270 (if (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7271 (string-match "<a href"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7272 (substring line 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7273 nil ; Don't do the replacement - it is inside a link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7274 (setq line (replace-match "<span style='color:red'>\\&</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7275 nil nil line 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7276
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7277 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7278 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7279 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7280 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7281 txt (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7282 (if (<= level umax) (setq head-count (+ head-count 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7283 (org-html-level-start level txt umax
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7284 (and org-export-with-toc (<= level umax))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7285 head-count))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7286
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7287 ((and org-export-with-tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7288 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7289 (if (not table-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7290 ;; New table starts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7291 (setq table-open t table-buffer nil table-orig-buffer nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7292 ;; Accumulate lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7293 (setq table-buffer (cons line table-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7294 table-orig-buffer (cons origline table-orig-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7295 (when (or (not lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7296 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7297 (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7298 (setq table-open nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7299 table-buffer (nreverse table-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7300 table-orig-buffer (nreverse table-orig-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7301 (insert (org-format-table-html table-buffer table-orig-buffer))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7302 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7303 ;; Normal lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7304 ;; Lines starting with "-", and empty lines make new paragraph.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7305 (if (string-match "^ *-\\|^[ \t]*$" line) (insert "<p>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7306 (insert line (if org-export-preserve-breaks "<br>\n" "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7307 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7308 (if org-export-html-with-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7309 (insert org-export-html-html-helper-timestamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7310 (insert "</body>\n</html>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7311 (normal-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7312 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7313 (goto-char (point-min)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7314
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7315 (defun org-format-table-html (lines olines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7316 "Find out which HTML converter to use and return the HTML code."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7317 (if (string-match "^[ \t]*|" (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7318 ;; A normal org table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7319 (org-format-org-table-html lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7320 ;; Table made by table.el - test for spanning
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7321 (let* ((hlines (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7322 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7323 (if (string-match "^[ \t]*\\+-" x) x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7324 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7325 lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7326 (first (car hlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7327 (ll (and (string-match "\\S-+" first)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7328 (match-string 0 first)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7329 (re (concat "^[ \t]*" (regexp-quote ll)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7330 (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7331 hlines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7332 (if (and (not spanning)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7333 (not org-export-prefer-native-exporter-for-tables))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7334 ;; We can use my own converter with HTML conversions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7335 (org-format-table-table-html lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7336 ;; Need to use the code generator in table.el, with the original text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7337 (org-format-table-table-html-using-table-generate-source olines)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7338
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7339 (defun org-format-org-table-html (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7340 "Format a table into html."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7341 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7342 (setq lines (nreverse lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7343 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7344 (setq lines (nreverse lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7345 (let ((head (and org-export-highlight-first-table-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7346 (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7347 (lambda (x) (string-match "^[ \t]*|-" x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7348 lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7349 lastline line fields html empty)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7350 (setq html (concat org-export-html-table-tag "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7351 (while (setq lastline line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7352 line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7353 (setq empty "&nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7354 (catch 'next-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7355 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7356 (if lastline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7357 ;; A hline: simulate an empty table row instead.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7358 (setq line (org-fake-empty-table-line lastline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7359 head nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7360 empty "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7361 ;; Ignore this line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7362 (throw 'next-line t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7363 ;; Break the line into fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7364 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7365 (setq html (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7366 html
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7367 "<tr>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7368 (mapconcat (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7369 (if (equal x "") (setq x empty))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7370 (if head
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7371 (concat "<th>" x "</th>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7372 (concat "<td valign=\"top\">" x "</td>")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7373 fields "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7374 "</tr>\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7375 (setq html (concat html "</table>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7376 html))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7377
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7378 (defun org-fake-empty-table-line (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7379 "Replace everything except \"|\" with spaces."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7380 (let ((i (length line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7381 (newstr (copy-sequence line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7382 (while (> i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7383 (setq i (1- i))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7384 (if (not (eq (aref newstr i) ?|))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7385 (aset newstr i ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7386 newstr))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7387
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7388 (defun org-format-table-table-html (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7389 "Format a table generated by table.el into html.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7390 This conversion does *not* use `table-generate-source' from table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7391 This has the advantage that Org-mode's HTML conversions can be used.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7392 But it has the disadvantage, that no cell- or row-spanning is allowed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7393 (let (line field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7394 (head org-export-highlight-first-table-line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7395 fields html empty)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7396 (setq html (concat org-export-html-table-tag "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7397 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7398 (setq empty "&nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7399 (catch 'next-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7400 (if (string-match "^[ \t]*\\+-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7401 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7402 (if field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7403 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7404 (setq html (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7405 html
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7406 "<tr>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7407 (mapconcat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7408 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7409 (if (equal x "") (setq x empty))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7410 (if head
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7411 (concat "<th valign=\"top\">" x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7412 "</th>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7413 (concat "<td valign=\"top\">" x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7414 "</td>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7415 field-buffer "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7416 "</tr>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7417 (setq head nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7418 (setq field-buffer nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7419 ;; Ignore this line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7420 (throw 'next-line t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7421 ;; Break the line into fields and store the fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7422 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7423 (if field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7424 (setq field-buffer (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7425 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7426 (concat x "<br>" (pop fields)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7427 field-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7428 (setq field-buffer fields))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7429 (setq html (concat html "</table>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7430 html))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7431
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7432 (defun org-format-table-table-html-using-table-generate-source (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7433 "Format a table into html, using `table-generate-source' from table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7434 This has the advantage that cell- or row-spanning is allowed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7435 But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7436 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7437 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7438 (set-buffer (get-buffer-create " org-tmp1 "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7439 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7440 (insert (mapconcat 'identity lines "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7441 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7442 (if (not (re-search-forward "|[^+]" nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7443 (error "Error processing table."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7444 (table-recognize-table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7445 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7446 (set-buffer (get-buffer-create " org-tmp2 "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7447 (erase-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7448 (table-generate-source 'html " org-tmp2 ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7449 (set-buffer " org-tmp2 ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7450 (buffer-substring (point-min) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7451
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7452 (defun org-html-expand (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7453 "Prepare STRING for HTML export. Applies all active conversions."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7454 ;; First check if there is a link in the line - if yes, apply conversions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7455 ;; only before the start of the link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7456 (let* ((m (string-match org-link-regexp string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7457 (s (if m (substring string 0 m) string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7458 (r (if m (substring string m) "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7459 ;; convert < to &lt; and > to &gt;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7460 (while (string-match "<" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7461 (setq s (replace-match "&lt;" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7462 (while (string-match ">" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7463 (setq s (replace-match "&gt;" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7464 (if org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7465 (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7466 (setq s (replace-match "<\\1>" nil nil s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7467 (if org-export-with-emphasize
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7468 (setq s (org-export-html-convert-emphasize s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7469 (if org-export-with-sub-superscripts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7470 (setq s (org-export-html-convert-sub-super s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7471 (if org-export-with-TeX-macros
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7472 (let ((start 0) wd ass)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7473 (while (setq start (string-match "\\\\\\([a-zA-Z]+\\)" s start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7474 (setq wd (match-string 1 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7475 (if (setq ass (assoc wd org-html-entities))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7476 (setq s (replace-match (or (cdr ass)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7477 (concat "&" (car ass) ";"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7478 t t s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7479 (setq start (+ start (length wd)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7480 (concat s r)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7481
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7482 (defun org-create-multibrace-regexp (left right n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7483 "Create a regular expression which will match a balanced sexp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7484 Opening delimiter is LEFT, and closing delimiter is RIGHT, both given
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7485 as single character strings.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7486 The regexp returned will match the entire expression including the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7487 delimiters. It will also define a single group which contains the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7488 match except for the outermost delimiters. The maximum depth of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7489 stacked delimiters is N. Escaping delimiters is not possible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7490 (let* ((nothing (concat "[^" "\\" left "\\" right "]*?"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7491 (or "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7492 (re nothing)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7493 (next (concat "\\(?:" nothing left nothing right "\\)+" nothing)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7494 (while (> n 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7495 (setq n (1- n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7496 re (concat re or next)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7497 next (concat "\\(?:" nothing left next right "\\)+" nothing)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7498 (concat left "\\(" re "\\)" right)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7499
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7500 (defvar org-match-substring-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7501 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7502 "\\([^\\]\\)\\([_^]\\)\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7503 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7504 "\\|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7505 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7506 "\\|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7507 "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7508 "The regular expression matching a sub- or superscript.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7509
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7510 (defun org-export-html-convert-sub-super (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7511 "Convert sub- and superscripts in STRING to HTML."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7512 (let (key c)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7513 (while (string-match org-match-substring-regexp string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7514 (setq key (if (string= (match-string 2 string) "_") "sub" "sup"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7515 (setq c (or (match-string 8 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7516 (match-string 6 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7517 (match-string 5 string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7518 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7519 (concat (match-string 1 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7520 "<" key ">" c "</" key ">")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7521 t t string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7522 (while (string-match "\\\\\\([_^]\\)" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7523 (setq string (replace-match (match-string 1 string) t t string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7524 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7525
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7526 (defun org-export-html-convert-emphasize (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7527 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7528 "\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7529 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7530 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7531 (concat "<b>" (match-string 3 string) "</b>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7532 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7533 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7534 "\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7535 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7536 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7537 (concat "<i>" (match-string 3 string) "</i>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7538 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7539 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7540 "\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7541 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7542 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7543 (concat "<u>" (match-string 3 string) "</u>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7544 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7545 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7546
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7547 (defun org-parse-key-lines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7548 "Find the special key lines with the information for exporters."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7549 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7550 (goto-char 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7551 (let ((re (org-make-options-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7552 '("TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7553 key)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7554 (while (re-search-forward re nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7555 (setq key (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7556 (cond ((string-equal key "TITLE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7557 (setq title (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7558 ((string-equal key "AUTHOR")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7559 (setq author (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7560 ((string-equal key "EMAIL")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7561 (setq email (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7562 ((string-equal key "LANGUAGE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7563 (setq language (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7564 ((string-equal key "TEXT")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7565 (setq text (concat text "\n" (match-string 2))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7566 ((string-equal key "OPTIONS")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7567 (setq options (match-string 2))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7568
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7569 (defun org-parse-export-options (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7570 "Parse the export options line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7571 (let ((op '(("H" . org-export-headline-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7572 ("num" . org-export-with-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7573 ("toc" . org-export-with-toc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7574 ("\\n" . org-export-preserve-breaks)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7575 ("@" . org-export-html-expand)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7576 (":" . org-export-with-fixed-width)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7577 ("|" . org-export-with-tables)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7578 ("^" . org-export-with-sub-superscripts)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7579 ("*" . org-export-with-emphasize)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7580 ("TeX" . org-export-with-TeX-macros)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7581 o)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7582 (while (setq o (pop op))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7583 (if (string-match (concat (regexp-quote (car o)) ":\\([^ \t\n\r;,.]*\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7584 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7585 (set (make-local-variable (cdr o))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7586 (car (read-from-string (match-string 1 s))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7587
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7588 (defun org-html-level-start (level title umax with-toc head-count)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7589 "Insert a new level in HTML export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7590 (let ((l (1+ (max level umax))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7591 (while (<= l org-level-max)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7592 (if (aref levels-open (1- l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7593 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7594 (org-html-level-close l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7595 (aset levels-open (1- l) nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7596 (setq l (1+ l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7597 (if (> level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7598 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7599 (if (aref levels-open (1- level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7600 (insert "<li>" title "<p>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7601 (aset levels-open (1- level) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7602 (insert "<ul><li>" title "<p>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7603 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7604 (setq title (concat (org-section-number level) " " title)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7605 (setq level (+ level 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7606 (if with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7607 (insert (format "\n<H%d><a name=\"sec-%d\">%s</a></H%d>\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7608 level head-count title level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7609 (insert (format "\n<H%d>%s</H%d>\n" level title level))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7610
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7611 (defun org-html-level-close (level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7612 "Terminate one level in HTML export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7613 (insert "</ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7614
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7615
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7616 ;; Variable holding the vector with section numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7617 (defvar org-section-numbers (make-vector org-level-max 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7618
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7619 (defun org-init-section-numbers ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7620 "Initialize the vector for the section numbers."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7621 (let* ((level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7622 (numbers (nreverse (org-split-string "" "\\.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7623 (depth (1- (length org-section-numbers)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7624 (i depth) number-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7625 (while (>= i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7626 (if (> i level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7627 (aset org-section-numbers i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7628 (setq number-string (or (car numbers) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7629 (if (string-match "\\`[A-Z]\\'" number-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7630 (aset org-section-numbers i
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7631 (- (string-to-char number-string) ?A -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7632 (aset org-section-numbers i (string-to-int number-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7633 (pop numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7634 (setq i (1- i)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7635
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7636 (defun org-section-number (&optional level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7637 "Return a string with the current section number.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7638 When LEVEL is non-nil, increase section numbers on that level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7639 (let* ((depth (1- (length org-section-numbers))) idx n (string ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7640 (when level
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7641 (when (> level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7642 (aset org-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7643 level (1+ (aref org-section-numbers level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7644 (setq idx (1+ level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7645 (while (<= idx depth)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7646 (if (not (= idx 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7647 (aset org-section-numbers idx 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7648 (setq idx (1+ idx))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7649 (setq idx 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7650 (while (<= idx depth)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7651 (setq n (aref org-section-numbers idx))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7652 (setq string (concat string (if (not (string= string "")) "." "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7653 (int-to-string n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7654 (setq idx (1+ idx)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7655 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7656 (if (string-match "\\`\\([@0]\\.\\)+" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7657 (setq string (replace-match "" nil nil string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7658 (if (string-match "\\(\\.0\\)+\\'" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7659 (setq string (replace-match "" nil nil string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7660 string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7661
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7662
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7663 ;;; Key bindings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7664
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7665 ;; - Bindings in Org-mode map are currently
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7666 ;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7667 ;; abcd fgh j lmnopqrstuvwxyz ? # -+ /= [] ; |,.<> \t necessary bindings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7668 ;; e (?) useful from outline-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7669 ;; i k @ expendable from outline-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7670 ;; 0123456789 ! $%^& * ()_{} " ~`' free
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7671
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7672 (define-key org-mode-map [(tab)] 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7673 (define-key org-mode-map "\C-i" 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7674 (define-key org-mode-map [(meta tab)] 'org-complete)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7675 (define-key org-mode-map "\M-\C-i" 'org-complete)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7676 (define-key org-mode-map [(meta shift left)] 'org-shiftmetaleft)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7677 (define-key org-mode-map [(meta left)] 'org-metaleft)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7678 (define-key org-mode-map [(meta shift right)] 'org-shiftmetaright)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7679 (define-key org-mode-map [(meta shift up)] 'org-shiftmetaup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7680 (define-key org-mode-map [(meta shift down)] 'org-shiftmetadown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7681 (define-key org-mode-map [(meta right)] 'org-metaright)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7682 (define-key org-mode-map [(meta up)] 'org-metaup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7683 (define-key org-mode-map [(meta down)] 'org-metadown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7684 ;(define-key org-mode-map "\C-c\C-h\C-w" 'org-cut-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7685 ;(define-key org-mode-map "\C-c\C-h\M-w" 'org-copy-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7686 ;(define-key org-mode-map "\C-c\C-h\C-y" 'org-paste-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7687 (define-key org-mode-map "\C-c\C-h\C-w" 'org-cut-special)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7688 (define-key org-mode-map "\C-c\C-h\M-w" 'org-copy-special)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7689 (define-key org-mode-map "\C-c\C-h\C-y" 'org-paste-special)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7690 (define-key org-mode-map "\C-c\C-j" 'org-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7691 (define-key org-mode-map "\C-c\C-t" 'org-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7692 (define-key org-mode-map "\C-c\C-s" 'org-schedule)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7693 (define-key org-mode-map "\C-c\C-d" 'org-deadline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7694 (define-key org-mode-map "\C-c;" 'org-toggle-comment)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7695 (define-key org-mode-map "\C-c\C-v" 'org-show-todo-tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7696 (define-key org-mode-map "\C-c\C-w" 'org-check-deadlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7697 (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7698 (define-key org-mode-map "\C-c\C-m" 'org-insert-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7699 (define-key org-mode-map "\M-\C-m" 'org-insert-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7700 (define-key org-mode-map "\C-c\C-l" 'org-insert-link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7701 (define-key org-mode-map "\C-c\C-o" 'org-open-at-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7702 (define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7703 (define-key org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7704 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7705 (define-key org-mode-map "\C-c\C-y" 'org-evaluate-time-range)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7706 (define-key org-mode-map "\C-c>" 'org-goto-calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7707 (define-key org-mode-map "\C-c<" 'org-date-from-calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7708 (define-key org-mode-map "\C-c[" 'org-add-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7709 (define-key org-mode-map "\C-c]" 'org-remove-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7710 (define-key org-mode-map "\C-c\C-r" 'org-timeline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7711 ;(define-key org-mode-map [(shift up)] 'org-timestamp-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7712 ;(define-key org-mode-map [(shift down)] 'org-timestamp-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7713 (define-key org-mode-map [(shift up)] 'org-shiftup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7714 (define-key org-mode-map [(shift down)] 'org-shiftdown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7715 (define-key org-mode-map [(shift left)] 'org-timestamp-down-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7716 (define-key org-mode-map [(shift right)] 'org-timestamp-up-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7717 (define-key org-mode-map "\C-c-" 'org-table-insert-hline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7718 ;; The following line is e.g. necessary for German keyboards under Suse Linux
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7719 (unless org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7720 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7721 (define-key org-mode-map [(shift tab)] 'org-shifttab)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7722 (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7723 (define-key org-mode-map [(return)] 'org-return)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7724 (define-key org-mode-map [(shift return)] 'org-table-copy-down)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7725 (define-key org-mode-map [(meta return)] 'org-meta-return)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7726 (define-key org-mode-map [(control up)] 'org-move-line-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7727 (define-key org-mode-map [(control down)] 'org-move-line-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7728 (define-key org-mode-map "\C-c?" 'org-table-current-column)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7729 (define-key org-mode-map "\C-c " 'org-table-blank-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7730 (define-key org-mode-map "\C-c+" 'org-table-sum)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7731 (define-key org-mode-map "\C-c|" 'org-table-toggle-vline-visibility)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7732 (define-key org-mode-map "\C-c=" 'org-table-eval-formula)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7733 (define-key org-mode-map "\C-c#" 'org-table-create-with-table.el)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7734 (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7735 (define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7736 (define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7737 (define-key org-mode-map "\C-c\C-xv" 'org-export-copy-visible)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7738 (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-copy-visible)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7739 (define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7740 (define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7741 (define-key org-mode-map "\C-c\C-xt" 'org-insert-export-options-template)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7742 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7743 (define-key org-mode-map "\C-c\C-xh" 'org-export-as-html)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7744 (define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7745
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7746
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7747 ;; FIXME: Do we really need to save match data in these commands?
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7748 ;; I would like to remove it in order to minimize impact.
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7749 ;; Self-insert already does not preserve it. How much resources used by this???
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7750
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7751 (defsubst org-table-p ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7752 (if (and (eq major-mode 'org-mode) font-lock-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7753 (eq (get-text-property (point) 'face) 'org-table-face)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7754 (save-match-data (org-at-table-p))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7755
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7756 (defun org-self-insert-command (N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7757 "Like `self-insert-command', use overwrite-mode for whitespace in tables.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7758 If the cursor is in a table looking at whitespace, the whitespace is
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7759 overwritten, and the table is not marked as requiring realignment."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7760 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7761 (if (and (org-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7762 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7763 (looking-at "[^|\n]* +|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7764 (let (org-table-may-need-update (pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7765 (goto-char (1- (match-end 0)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7766 (delete-backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7767 (goto-char (match-beginning 0))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7768 (self-insert-command N))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7769 (setq org-table-may-need-update t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7770 (self-insert-command N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7771
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7772 ;; FIXME:
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7773 ;; The following two functions might still be optimized to trigger
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7774 ;; re-alignment less frequently.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7775
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7776 (defun org-delete-backward-char (N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7777 "Like `delete-backward-char', insert whitespace at field end in tables.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7778 When deleting backwards, in tables this function will insert whitespace in
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7779 front of the next \"|\" separator, to keep the table aligned. The table will
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7780 still be marked for re-alignment, because a narrow field may lead to a
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7781 reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7782 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7783 (if (and (org-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7784 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7785 (looking-at ".*?|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7786 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7787 (backward-delete-char N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7788 (skip-chars-forward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7789 (insert " ")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7790 (goto-char (1- pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7791 (backward-delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7792
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7793 (defun org-delete-char (N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7794 "Like `delete-char', but insert whitespace at field end in tables.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7795 When deleting characters, in tables this function will insert whitespace in
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7796 front of the next \"|\" separator, to keep the table aligned. The table
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7797 will still be marked for re-alignment, because a narrow field may lead to
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7798 a reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7799 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7800 (if (and (org-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7801 (eq N 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7802 (if (looking-at ".*?|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7803 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7804 (replace-match (concat
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7805 (substring (match-string 0) 1 -1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7806 " |"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7807 (goto-char pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7808 (delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7809
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7810 ;; How to do this: Measure non-white length of current string
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7811 ;; If equal to column width, we should realign.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7812
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7813 (when (eq org-enable-table-editor 'optimized)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7814 ;; If the user wants maximum table support, we need to hijack
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7815 ;; some standard editing functions
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7816 (substitute-key-definition 'self-insert-command 'org-self-insert-command
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7817 org-mode-map global-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7818 (substitute-key-definition 'delete-char 'org-delete-char
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7819 org-mode-map global-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7820 (substitute-key-definition 'delete-backward-char 'org-delete-backward-char
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7821 org-mode-map global-map)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7822 (define-key org-mode-map "|" 'self-insert-command))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7823
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7824 (defun org-shiftcursor-error ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7825 "Throw an error because Shift-Cursor command was applied in wrong context."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7826 (error "This command is only active in tables and on headlines."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7827
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7828 (defun org-shifttab ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7829 "Call `(org-cycle t)' or `org-table-previous-field'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7830 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7831 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7832 ((org-at-table-p) (org-table-previous-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7833 (t (org-cycle '(4)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7834
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7835 (defun org-shiftmetaleft (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7836 "Call `org-promote-subtree' or `org-table-delete-column'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7837 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7838 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7839 ((org-at-table-p) (org-table-delete-column arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7840 ((org-on-heading-p) (org-promote-subtree arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7841 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7842 (defun org-shiftmetaright (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7843 "Call `org-demote-subtree' or `org-table-insert-column'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7844 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7845 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7846 ((org-at-table-p) (org-table-insert-column arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7847 ((org-on-heading-p) (org-demote-subtree arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7848 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7849 (defun org-shiftmetaup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7850 "Call `org-move-subtree-up' or `org-table-kill-row'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7851 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7852 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7853 ((org-at-table-p) (org-table-kill-row arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7854 ((org-on-heading-p) (org-move-subtree-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7855 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7856 (defun org-shiftmetadown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7857 "Call `org-move-subtree-down' or `org-table-insert-row'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7858 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7859 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7860 ((org-at-table-p) (org-table-insert-row arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7861 ((org-on-heading-p) (org-move-subtree-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7862 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7863
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7864 (defun org-metaleft (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7865 "Call `org-do-promote' or `org-table-move-column' to left."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7866 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7867 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7868 ((org-at-table-p) (org-table-move-column 'left))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7869 ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7870 (t (backward-word (prefix-numeric-value arg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7871 (defun org-metaright (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7872 "Call `org-do-demote' or `org-table-move-column' to right."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7873 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7874 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7875 ((org-at-table-p) (org-table-move-column nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7876 ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7877 (t (forward-word (prefix-numeric-value arg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7878 (defun org-metaup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7879 "Call `org-move-subtree-up' or `org-table-move-row' up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7880 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7881 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7882 ((org-at-table-p) (org-table-move-row 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7883 ((org-on-heading-p) (org-move-subtree-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7884 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7885 (defun org-metadown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7886 "Call `org-move-subtree-down' or `org-table-move-row' down."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7887 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7888 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7889 ((org-at-table-p) (org-table-move-row nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7890 ((org-on-heading-p) (org-move-subtree-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7891 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7892
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7893 (defun org-shiftup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7894 "Call `org-timestamp-up' or `org-priority-up'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7895 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7896 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7897 ((org-at-timestamp-p) (org-timestamp-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7898 (t (org-priority-up))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7899
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7900 (defun org-shiftdown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7901 "Call `org-timestamp-down' or `org-priority-down'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7902 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7903 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7904 ((org-at-timestamp-p) (org-timestamp-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7905 (t (org-priority-down))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7906
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7907 (defun org-copy-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7908 "Call either `org-table-copy' or `org-copy-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7909 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7910 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7911 (org-table-copy-region arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7912 (org-copy-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7913
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7914 (defun org-cut-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7915 "Call either `org-table-copy' or `org-copy-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7916 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7917 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7918 (org-table-cut-region arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7919 (org-cut-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7920
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7921 (defun org-paste-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7922 "Call either `org-table-paste-rectangle' or `org-paste-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7923 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7924 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7925 (org-table-paste-rectangle arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7926 (org-paste-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7927
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7928 (defun org-ctrl-c-ctrl-c (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7929 "Call realign table, or recognize a table.el table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7930 When the cursor is inside a table created by the table.el package,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7931 activate that table. Otherwise, if the cursor is at a normal table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7932 created with org.el, re-align that table. This command works even if
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7933 the automatic table editor has been turned off."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7934 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7935 (let ((org-enable-table-editor t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7936 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7937 ((org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7938 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7939 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7940 (re-search-forward "|" (save-excursion (end-of-line 2) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7941 (table-recognize-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7942 ((org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7943 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7944 ((org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7945 (org-table-convert-region (region-beginning) (region-end) arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7946 ((and (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7947 (if (y-or-n-p "Convert inactive region to table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7948 (org-table-convert-region (region-beginning) (region-end) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7949 (error "Abort")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7950 (t (error "No table at point, and no region to make one.")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7951
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7952 (defun org-return (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7953 "Call `org-table-next-row' or `newline'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7954 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7955 (cond
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7956 ((org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7957 (org-table-justify-field-maybe)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7958 (org-table-next-row))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7959 (t (newline))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7960
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7961 (defun org-meta-return (&optional arg)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7962 "Call `org-insert-heading' or `org-table-wrap-region'."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7963 (interactive "P")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7964 (cond
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7965 ((org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7966 (org-table-wrap-region arg))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7967 (t (org-insert-heading arg))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7968
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7969 ;;; Menu entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7970
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7971 ;; First, remove the outline menus.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7972 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7973 (add-hook 'org-mode-hook
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7974 (lambda ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7975 (delete-menu-item '("Headings"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7976 (delete-menu-item '("Show"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7977 (delete-menu-item '("Hide"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7978 (set-menubar-dirty-flag)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7979 (setq org-mode-map (delq (assoc 'menu-bar (cdr org-mode-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7980 org-mode-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7981
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7982 ;; Define the Org-mode menus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7983 (easy-menu-define org-org-menu org-mode-map "Org menu"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7984 '("Org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7985 ["Cycle Visibility" org-cycle (or (bobp) (outline-on-heading-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7986 ["Sparse Tree" org-occur t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7987 ["Show All" show-all t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7988 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7989 ["New Heading" org-insert-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7990 ("Navigate Headings"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7991 ["Up" outline-up-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7992 ["Next" outline-next-visible-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7993 ["Previous" outline-previous-visible-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7994 ["Next Same Level" outline-forward-same-level t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7995 ["Previous Same Level" outline-backward-same-level t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7996 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7997 ["Jump" org-goto t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7998 ("Edit Structure"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7999 ["Move subtree up" org-shiftmetaup (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8000 ["Move subtree down" org-shiftmetadown (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8001 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8002 ["Copy Subtree" org-copy-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8003 ["Cut Subtree" org-cut-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8004 ["Paste Subtree" org-paste-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8005 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8006 ["Promote Heading" org-metaleft (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8007 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8008 ["Demote Heading" org-metaright (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8009 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8010 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8011 ("TODO lists"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8012 ["TODO/DONE/-" org-todo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8013 ["Show TODO Tree" org-show-todo-tree t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8014 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8015 ["Set priority" org-priority t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8016 ["Priority up" org-shiftup t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8017 ["Priority down" org-shiftdown t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8018 ("Dates and Scheduling"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8019 ["Timestamp" org-time-stamp t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8020 ("Change Date"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8021 ["1 day later" org-timestamp-up-day t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8022 ["1 day earlier" org-timestamp-down-day t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8023 ["1 ... later" org-shiftup t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8024 ["1 ... earlier" org-shiftdown t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8025 ["Compute Time Range" org-evaluate-time-range t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8026 ["Schedule Item" org-schedule t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8027 ["Deadline" org-deadline t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8028 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8029 ["Goto Calendar" org-goto-calendar t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8030 ["Date from Calendar" org-date-from-calendar t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8031 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8032 ("Timeline/Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8033 ["Show TODO Tree this file" org-show-todo-tree t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8034 ["Check Deadlines this file" org-check-deadlines t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8035 ["Timeline current file" org-timeline t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8036 "--"
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8037 ["Adenda (multifile)" org-agenda t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8038 ("File List for Agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8039 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8040 ("Hyperlinks"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8041 ["Store Link (global)" org-store-link t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8042 ["Insert Link" org-insert-link t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8043 ["Follow Link" org-open-at-point t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8044 ;; ["BBDB" org-bbdb-name t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8045 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8046 ("Table"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8047 ["Align" org-ctrl-c-ctrl-c (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8048 ["Next field" org-cycle (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8049 ["Previous Field" org-shifttab (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8050 ["Next row" org-return (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8051 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8052 ["Blank field" org-table-blank-field (org-at-table-p)]
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
8053 ["Copy field from above" org-table-copy-down (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8054 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8055 ("Column"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8056 ["Move column left" org-metaleft (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8057 ["Move column right" org-metaright (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8058 ["Delete column" org-shiftmetaleft (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8059 ["Insert column" org-shiftmetaright (org-at-table-p)])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8060 ("Row"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8061 ["Move row up" org-metaup (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8062 ["Move row down" org-metadown (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8063 ["Delete row" org-shiftmetaup (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8064 ["Insert row" org-shiftmetadown (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8065 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8066 ["Insert hline" org-table-insert-hline (org-at-table-p)])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8067 ("Rectangle"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8068 ["Copy rectangle" org-copy-special (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8069 ["Cut rectangle" org-cut-special (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8070 ["Paste rectangle" org-paste-special (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8071 ["Fill rectangle" org-table-wrap-region (org-at-table-p)])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8072 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8073 ["Which column?" org-table-current-column (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8074 ["Sum column/rectangle" org-table-sum
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8075 (or (org-at-table-p) (org-region-active-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8076 ["Eval formula" org-table-eval-formula (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8077 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8078 ["Invisible Vlines" org-table-toggle-vline-visibility
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8079 :style toggle :selected (org-in-invisibility-spec-p '(org-table))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8080 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8081 ["Create" org-table-create (and (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8082 org-enable-table-editor)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8083 ["Convert region" org-ctrl-c-ctrl-c (not (org-at-table-p 'any))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8084 ["Import from file" org-table-import (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8085 ["Export to file" org-table-export (org-at-table-p)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8086 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8087 ["Create/convert from/to table.el" org-table-create-with-table.el t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8088 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8089 ("Export"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8090 ["ASCII" org-export-as-ascii t]
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
8091 ["Extract visible text" org-export-copy-visible t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8092 ["HTML" org-export-as-html t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8093 ["HTML, and open" org-export-as-html-and-open t]
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
8094 ["OPML" org-export-as-opml nil]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8095 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8096 ["Option template" org-insert-export-options-template t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8097 ["Toggle fixed width" org-toggle-fixed-width-section t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8098 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8099 ("Documentation"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8100 ["Show Version" org-version t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8101 ["Info Documentation" org-info t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8102 ("Customize"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8103 ["Browse Org Group" org-customize t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8104 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8105 ["Build Full Customize Menu" org-create-customize-menu
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8106 (fboundp 'customize-menu-create)])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8107 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8108
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8109
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8110 (defun org-info (&optional node)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8111 "Read documentation for Org-mode in the info system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8112 With optional NODE, go directly to that node."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8113 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8114 (require 'info)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8115 (Info-goto-node (format "(org)%s" (or node ""))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8116
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8117
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8118 (defun org-install-agenda-files-menu ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8119 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8120 '("Org") "File List for Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8121 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8122 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8123 ["Edit file list" (customize-variable 'org-agenda-files) t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8124 ["Add current file to list" org-add-file t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8125 ["Remove current file from list" org-remove-file t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8126 "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8127 (mapcar 'org-file-menu-entry org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8128
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8129 ;;; Documentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8130
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8131 (defun org-customize ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8132 "Call the customize function with org as argument."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8133 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8134 (customize-browse 'org))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8135
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8136 (defun org-create-customize-menu ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8137 "Create a full customization menu for Org-mode, insert it into the menu."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8138 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8139 (if (fboundp 'customize-menu-create)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8140 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8141 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8142 '("Org") "Customize"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8143 `(["Browse Org group" org-customize t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8144 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8145 ,(customize-menu-create 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8146 ["Set" Custom-set t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8147 ["Save" Custom-save t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8148 ["Reset to Current" Custom-reset-current t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8149 ["Reset to Saved" Custom-reset-saved t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8150 ["Reset to Standard Settings" Custom-reset-standard t]))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8151 (message "\"Org\"-menu now contains full customization menu"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8152 (error "Cannot expand menu (outdated version of cus-edit.el)")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8153
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8154 ;;; Miscellaneous stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8155
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8156 (defun org-move-line-down (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8157 "Move the current line up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8158 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8159 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8160 beg end pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8161 (beginning-of-line 1) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8162 (beginning-of-line 2) (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8163 (beginning-of-line (+ 1 arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8164 (setq pos (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8165 (insert (delete-and-extract-region beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8166 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8167 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8168
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8169 (defun org-move-line-up (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8170 "Move the current line up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8171 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8172 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8173 beg end pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8174 (beginning-of-line 1) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8175 (beginning-of-line 2) (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8176 (beginning-of-line (+ -2 arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8177 (setq pos (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8178 (insert (delete-and-extract-region beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8179 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8180 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8181
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8182 ;; Functions needed for Emacs/XEmacs region compatibility
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8183
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8184 (defun org-region-active-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8185 "Is transient-mark-mode on and the region active?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8186 Works on both Emacs and XEmacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8187 (if org-ignore-region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8188 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8189 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8190 (and zmacs-regions (region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8191 (and transient-mark-mode mark-active))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8192
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8193 (defun org-add-to-invisibility-spec (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8194 "Add elements to `buffer-invisibility-spec'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8195 See documentation for `buffer-invisibility-spec' for the kind of elements
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8196 that can be added."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8197 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8198 ((fboundp 'add-to-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8199 (add-to-invisibility-spec arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8200 ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8201 (setq buffer-invisibility-spec (list arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8202 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8203 (setq buffer-invisibility-spec
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8204 (cons arg buffer-invisibility-spec)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8205
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8206 (defun org-remove-from-invisibility-spec (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8207 "Remove elements from `buffer-invisibility-spec'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8208 (if (fboundp 'remove-from-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8209 (remove-from-invisibility-spec arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8210 (if (consp buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8211 (setq buffer-invisibility-spec
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8212 (delete arg buffer-invisibility-spec)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8213
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8214 (defun org-in-invisibility-spec-p (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8215 "Is ARG a member of `buffer-invisibility-spec'?."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8216 (if (consp buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8217 (member arg buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8218 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8219
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8220 (defun org-image-file-name-regexp ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8221 "Return regexp matching the file names of images."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8222 (if (fboundp 'image-file-name-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8223 (image-file-name-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8224 (let ((image-file-name-extensions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8225 '("png" "jpeg" "jpg" "gif" "tiff" "tif"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8226 "xbm" "xpm" "pbm" "pgm" "ppm")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8227 (concat "\\."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8228 (regexp-opt (nconc (mapcar 'upcase
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8229 image-file-name-extensions)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8230 image-file-name-extensions)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8231 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8232 "\\'"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8233
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8234 ;; Functions needed for compatibility with old outline.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8235
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8236 ;; The following functions capture almost the entire compatibility code
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8237 ;; between the different versions of outline-mode. The only other place
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8238 ;; where this is important are the font-lock-keywords. Search for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8239 ;; `org-noutline-p' to find it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8240
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8241 ;; C-a should go to the beginning of a *visible* line, also in the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8242 ;; new outline.el. I guess this should be patched into Emacs?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8243 (defun org-beginning-of-line ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8244 "Go to the beginning of the current line. If that is invisible, continue
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8245 to a visible line beginning. This makes the function of C-a more intuitive."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8246 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8247 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8248 (if (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8249 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8250 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8251 (if (org-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8252 (while (and (not (bobp)) (org-invisible-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8253 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8254 (beginning-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8255 (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8256 (when org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8257 (define-key org-mode-map "\C-a" 'org-beginning-of-line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8258
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8259 (defun org-invisible-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8260 "Check if point is at a character currently not visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8261 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8262 ;; Early versions of noutline don't have `outline-invisible-p'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8263 (if (fboundp 'outline-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8264 (outline-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8265 (get-char-property (point) 'invisible))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8266 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8267 (skip-chars-backward "^\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8268 (if (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8269 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8270 (equal (char-before) ?\r)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8271
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8272 (defun org-back-to-heading (&optional invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8273 "Move to previous heading line, or beg of this line if it's a heading.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8274 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8275 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8276 (outline-back-to-heading invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8277 (if (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8278 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8279 (if (re-search-backward (concat (if invisible-ok "[\r\n]" "^")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8280 outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8281 nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8282 (if invisible-ok
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8283 (progn (forward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8284 (looking-at outline-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8285 (error "Before first heading")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8286
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8287 (defun org-on-heading-p (&optional invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8288 "Return t if point is on a (visible) heading line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8289 If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8290 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8291 (outline-on-heading-p 'invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8292 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8293 (skip-chars-backward "^\n\r")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8294 (and (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8295 (or invisible-ok
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8296 (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8297 (equal (char-before) ?\n))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8298
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8299 (defun org-up-heading-all (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8300 "Move to the heading line of which the present line is a subheading.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8301 This function considers both visible and invisible heading lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8302 With argument, move up ARG levels."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8303 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8304 (outline-up-heading-all arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8305 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8306 (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8307 (if (<= (- (match-end 0) (match-beginning 0)) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8308 (error "Cannot move up %d levels" arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8309 (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8310 (concat "[\n\r]" (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8311 (make-string (- (match-end 0) (match-beginning 0) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8312 ?*))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8313 "[^*]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8314 (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8315
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8316 (defun org-show-hidden-entry ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8317 "Show an entry where even the heading is hidden."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8318 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8319 (if (not org-noutline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8320 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8321 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8322 (org-flag-heading nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8323 (show-entry)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8324
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8325 (defun org-check-occur-regexp (regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8326 "If REGEXP starts with \"^\", modify it to check for \\r as well.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8327 Of course, only for the old outline mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8328 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8329 regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8330 (if (string-match "^\\^" regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8331 (concat "[\n\r]" (substring regexp 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8332 regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8333
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8334 (defun org-flag-heading (flag &optional entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8335 "Flag the current heading. FLAG non-nil means make invisible.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8336 When ENTRY is non-nil, show the entire entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8337 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8338 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8339 (if (not org-noutline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8340 ;; Make the current headline visible
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8341 (outline-flag-region (max 1 (1- (point))) (point) (if flag ?\r ?\n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8342 ;; Check if we should show the entire entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8343 (if entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8344 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8345 (show-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8346 (save-excursion ;; FIXME: Is this the fix for points in the -|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8347 ;; middle of text? |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8348 (and (outline-next-heading) ;; |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8349 (org-flag-heading nil)))) ; show the next heading _|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8350 (outline-flag-region (max 1 (1- (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8351 (save-excursion (outline-end-of-heading) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8352 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8353 flag
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8354 (if flag ?\r ?\n))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8355
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8356 (defun org-make-options-regexp (kwds)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8357 "Make a regular expression for keyword lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8358 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8359 (if org-noutline-p "^" "[\n\r]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8360 "#?[ \t]*\\+\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8361 (mapconcat 'regexp-quote kwds "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8362 "\\):[ \t]*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8363 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8364
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8365 ;; Advise the bookmark-jump function to make jump position visible
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8366 ;; Wrapped into eval-after-load to avoid loading advice unnecessarily
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8367 (eval-after-load "bookmark"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8368 '(defadvice bookmark-jump (after org-make-visible activate)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8369 "Make the position visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8370 (and (eq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8371 (org-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8372 (org-show-hierarchy-above))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8373
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8374 ;;; Finish up
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8375
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8376 (provide 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8377
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8378 (run-hooks 'org-load-hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8379
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8380 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8381
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8382 ;;; org.el ends here
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8383
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
8384
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
8385