annotate lisp/textmodes/org.el @ 62244:1053cf8f89ea

(Top): Update to the current structure of the manual.
author Lute Kamstra <lute@gnu.org>
date Wed, 11 May 2005 23:25:27 +0000
parents fab4f3bb60e0
children 153ddc124932 62afea0771d8
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/
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8 ;; Version: 3.08
61134
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.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
77 ;; The distribution also contains a PDF version of it. At the homepage
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
78 ;; of Org-mode, you can read 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 ;; -------
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
82 ;; Version 3.08
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
83 ;; - "|" no longer allowed as part of a link, to allow links in tables.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
84 ;; - The prefix of items in the agenda buffer can be configured.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
85 ;; - Cleanup.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
86 ;;
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
87 ;; Version 3.07
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
88 ;; - Some folding incinsistencies removed.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
89 ;; - BBDB links to company-only entries.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
90 ;; - Bug fixes and global cleanup.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
91 ;;
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
92 ;; Version 3.06
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
93 ;; - M-S-RET inserts a new TODO heading.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
94 ;; - New startup option `content'.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
95 ;; - Better visual response when TODO items in agenda change status.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
96 ;; - Window positioning after visibility state changes optimized and made
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
97 ;; configurable. See `org-cycle-hook' and `org-occur-hook'.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
98 ;;
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
99 ;; 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
100 ;; - 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
101 ;; 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
102 ;; - 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
103 ;; - 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
104 ;; - 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
105 ;; - 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
106 ;;
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
107 ;; Version 3.04
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
108 ;; - 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
109 ;; 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
110 ;; - 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
111 ;; into arbitrary major modes.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
112 ;; - 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
113 ;; - 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
114 ;; - 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
115 ;;
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; Version 3.03
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; - 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
118 ;; - 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
119 ;; - Timeline now always contains today, and `.' jumps to it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; - Table editor:
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
121 ;; - cut and paste of rectangular regions in tables
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; - command to convert org-mode table to table.el table and back
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; - command to treat several cells like a paragraph and fill it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; - command to convert a buffer region to a table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; - import/export tables as tab-separated files (exchange with Excel)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; - Agenda:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; - Sorting mechanism for agenda items rewritten from scratch.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; - Sorting fully configurable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; - Entries specifying a time are sorted together.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; - Completion also covers option keywords after `#-'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; - Bug fixes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; Version 3.01
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;; - New reference card, thanks to Philip Rooke for creating it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; - Single file agenda renamed to "Timeline". It no longer shows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; warnings about upcoming deadlines/overdue scheduled items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; That functionality is now limited to the (multifile) agenda.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; - When reading a date, the calendar can be manipulated with keys.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; - Link support for RMAIL and Wanderlust (from planner.el, untested)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; - Minor bug fixes and documentation improvements.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;;; Code:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
144 (eval-when-compile (require 'cl) (require 'calendar))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (require 'outline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (require 'time-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (require 'easymenu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;; Customization variables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
151 (defvar org-version "3.08"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "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
153 (defun org-version ()
8e7a2f6f9fa7 (org-version): Unnecessary prefix arg removed.
Carsten Dominik <dominik@science.uva.nl>
parents: 59547
diff changeset
154 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (message "Org-mode version %s" org-version))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; The following two constants are for compatibility with different
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; Emacs versions (Emacs versus XEmacs) and with different versions of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;; 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
160 ;; constants.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (defconst org-xemacs-p (featurep 'xemacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 "Are we running xemacs?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (defconst org-noutline-p (featurep 'noutline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 "Are we using the new outline mode?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (defgroup org nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 "Outline-based notes management and organizer "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 :tag "Org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 :group 'outlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 :group 'hypermedia
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 :group 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (defgroup org-startup nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 "Options concerning startup of Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 :tag "Org Startup"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (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
179 "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
180 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
181 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
182
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
183 #+STARTUP: fold
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
184 #+STARTUP: nofold
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
185 #+STARTUP: content"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 :group 'org-startup
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
187 :type '(choice
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
188 (const :tag "nofold: show all" nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
189 (const :tag "fold: overview" t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
190 (const :tag "content: all headlines" content)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (defcustom org-startup-truncated t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 "Non-nil means, entering Org-mode will set `truncate-lines'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 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
195 uninteresting. Also tables look terrible when wrapped."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (defcustom org-startup-with-deadline-check nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 "Non-nil means, entering Org-mode will run the deadline check.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 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
202 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
203 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
204 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
205
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
206 #+STARTUP: dlcheck
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
207 #+STARTUP: nodlcheck"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
61312
6939a6683ac3 (org-diary-default-entry): Fixed call to
Carsten Dominik <dominik@science.uva.nl>
parents: 61134
diff changeset
211 (defcustom org-insert-mode-line-in-empty-file nil
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 "Non-nil means insert the first line setting Org-mode in empty files.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
213 When the function `org-mode' is called interactively in an empty file, this
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 normally means that the file name does not automatically trigger Org-mode.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 To ensure that the file will always be in Org-mode in the future, a
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
216 line enforcing Org-mode will be inserted into the buffer, if this option
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
217 has been set."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (defgroup org-keywords nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 "Options concerning TODO items in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 :tag "Org Keywords"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (defcustom org-todo-keywords '("TODO" "DONE")
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
227 "List of TODO entry keywords.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
228 \\<org-mode-map>By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 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
230 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
231 etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 The command \\[org-todo] cycles an entry through these states, and an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 additional state where no keyword is present. For details about this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 cycling, see also the variable `org-todo-interpretation'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 :type '(repeat (string :tag "Keyword")))
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 (defcustom org-todo-interpretation 'sequence
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
240 "Controls how TODO keywords are interpreted.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
241 \\<org-mode-map>Possible values are `sequence' and `type'.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 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
243 states. There are two ways how these keywords can be used:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 - 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
246 (setq org-todo-keywords '(\"TODO\" \"STARTED\" \"VERIFY\" \"DONE\")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 - As different types of TODO items, for example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (setq org-todo-keywords '(\"URGENT\" \"RELAXED\" \"REMIND\" \"FOR_TOM\" \"DONE\")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 org-todo-interpretation 'type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 When the states are interpreted as a sequence, \\[org-todo] always cycles
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 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
255 \\[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
256 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
257 later to VERIFY and finally to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 When the states are interpreted as types, \\[org-todo] still cycles through
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 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
261 select the type. However, if not called immediately after a previous
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 \\[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
263 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
264 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
265 RELAXED will not be changed REMIND, but directly to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 You can create a large number of types. To initially select a
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
268 type, it is then best to use \\[universal-argument] \\[org-todo] in order to specify the
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 type with completion. Of course, you can also type the keyword
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 directly into the buffer. M-TAB completes TODO keywords at the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 beginning of a headline."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 :type '(choice (const sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (const type)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (defcustom org-default-priority ?B
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 "The default priority of TODO items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 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
279 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 :type 'character)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (defcustom org-lowest-priority ?C
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "The lowest priority of TODO items. A character like ?A, ?B etc."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 :type 'character)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (defcustom org-deadline-string "DEADLINE:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 "String to mark deadline entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 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
290 terminated by a colon. You can insert a schedule keyword and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 a timestamp with \\[org-deadline].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 :type 'string)
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-scheduled-string "SCHEDULED:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 "String to mark scheduled TODO entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 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
299 terminated by a colon. You can insert a schedule keyword and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 a timestamp with \\[org-schedule].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (defcustom org-comment-string "COMMENT"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 "Entries starting with this keyword will never be exported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 An entry can be toggled between COMMENT and normal with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 \\[org-toggle-comment].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (defcustom org-after-todo-state-change-hook nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 "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
315 The new state (a string with a todo keyword, or nil) is available in the
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
316 Lisp variable `state'."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 :type 'hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 ;; Variables for pre-computed regular expressions, all buffer local
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (defvar org-todo-kwd-priority-p nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 "Do TODO items have priorities?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (make-variable-buffer-local 'org-todo-kwd-priority-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (defvar org-todo-kwd-max-priority nil
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
325 "Maximum priority of TODO items.")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (make-variable-buffer-local 'org-todo-kwd-max-priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (defvar org-ds-keyword-length 12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 "Maximum length of the Deadline and SCHEDULED keywords.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (make-variable-buffer-local 'org-ds-keyword-length)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (defvar org-done-string nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 "The last string in `org-todo-keywords', indicating an item is DONE.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (make-variable-buffer-local 'org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (defvar org-todo-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 "Matches any of the TODO state keywords.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (make-variable-buffer-local 'org-todo-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (defvar org-not-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 "Matches any of the TODO state keywords except the last one.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (make-variable-buffer-local 'org-not-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (defvar org-todo-line-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 "Matches a headline and puts TODO state into group 2 if present.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (make-variable-buffer-local 'org-todo-line-regexp)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
342 (defvar org-nl-done-regexp nil
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 "Matches newline followed by a headline with the DONE keyword.")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
344 (make-variable-buffer-local 'org-nl-done-regexp)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (defvar org-looking-at-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 "Matches the DONE keyword a point.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (make-variable-buffer-local 'org-looking-at-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (defvar org-deadline-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 "Matches the DEADLINE keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (make-variable-buffer-local 'org-deadline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (defvar org-deadline-time-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 "Matches the DEADLINE keyword together with a time stamp.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (make-variable-buffer-local 'org-deadline-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (defvar org-deadline-line-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 "Matches the DEADLINE keyword and the rest of the line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (make-variable-buffer-local 'org-deadline-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (defvar org-scheduled-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 "Matches the SCHEDULED keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (make-variable-buffer-local 'org-scheduled-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (defvar org-scheduled-time-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 "Matches the SCHEDULED keyword together with a time stamp.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (make-variable-buffer-local 'org-scheduled-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
364 (defvar org-category nil
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
365 "Variable used by org files to set a category for agenda display.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
366 Such files should use a file variable to set it, for example
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
367
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
368 -*- mode: org; org-category: \"ELisp\"
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
369
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
370 If the file does not specify a category, the file's base name
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
371 is used instead.")
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
372
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
373 (defun org-set-regexps-and-options ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 "Precompute regular expressions for current buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (when (eq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (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
377 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (splitre "[ \t]+")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 kwds int key value cat)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
380 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
381 (save-restriction
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (while (re-search-forward re nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (setq key (match-string 1) value (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 ((equal key "CATEGORY")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
388 (if (string-match "[ \t]+$" value)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
389 (setq value (replace-match "" t t value)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
390 (setq cat (intern value)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 ((equal key "SEQ_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (setq int 'sequence
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 kwds (append kwds (org-split-string value splitre))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 ((equal key "PRI_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (setq int 'priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 kwds (append kwds (org-split-string value splitre))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 ((equal key "TYP_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (setq int 'type
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
399 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
400 ((equal key "STARTUP")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
401 (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
402 (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
403 ("nofold" org-startup-folded nil)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
404 ("content" org-startup-folded content)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
405 ("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
406 ("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
407 l var val)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
408 (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
409 (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
410 (set (make-local-variable var) val)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (and cat (set (make-local-variable 'org-category) cat))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (and kwds (set (make-local-variable 'org-todo-keywords) kwds))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (and int (set (make-local-variable 'org-todo-interpretation) int)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 ;; Compute the regular expressions and other local variables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 org-todo-kwd-max-priority (1- (length org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 org-ds-keyword-length (+ 2 (max (length org-deadline-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (length org-scheduled-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 org-done-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (nth (1- (length org-todo-keywords)) org-todo-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 org-todo-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 "\\|") "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 org-not-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (concat "\\<\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (mapconcat 'regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (nreverse (cdr (reverse org-todo-keywords)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 org-todo-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (concat "^\\(\\*+\\)[ \t]*\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (mapconcat 'regexp-quote org-todo-keywords "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 "\\)? *\\(.*\\)")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
435 org-nl-done-regexp
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 org-looking-at-done-regexp (concat "^" org-done-string "\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 org-deadline-regexp (concat "\\<" org-deadline-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 org-deadline-time-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 org-deadline-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (concat "\\<\\(" org-deadline-string "\\).*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 org-scheduled-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (concat "\\<" org-scheduled-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 org-scheduled-time-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (org-set-font-lock-defaults)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (defgroup org-time nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 "Options concerning time stamps and deadlines in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 :tag "Org Time"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (defcustom org-deadline-warning-days 30
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 "No. of days before expiration during which a deadline becomes active.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 This variable governs the display in the org file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (defcustom org-popup-calendar-for-date-prompt t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 "Non-nil means, pop up a calendar when prompting for a date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 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
463 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
464 When nil, only the minibuffer will be available."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (defcustom org-calendar-follow-timestamp-change t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 "Non-nil means, make the calendar window follow timestamp changes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 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
471 moved to the new date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (defgroup org-agenda nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 "Options concerning agenda display Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 :tag "Org Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (defcustom org-agenda-files nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 "A list of org files for agenda/diary display.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 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
483 \\[org-remove-file]. You can also use customize to edit the list."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 :type '(repeat file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (defcustom org-select-timeline-window t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 "Non-nil means, after creating a timeline, move cursor into Timeline window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 When nil, cursor will remain in the current window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 :type 'boolean)
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 (defcustom org-select-agenda-window t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 "Non-nil means, after creating an agenda, move cursor into Agenda window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 When nil, cursor will remain in the current window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
499 (defcustom org-fit-agenda-window t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
500 "Non-nil means, change window size of agenda to fit content."
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
501 :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
502 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
503
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (defcustom org-agenda-show-all-dates t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 "Non-nil means, `org-agenda' shows every day in the selected range.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 When nil, only the days which actually have entries are shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 ;; 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
511 ;; require a variable ndays treatment.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (defcustom org-agenda-start-on-weekday 1
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 "Non-nil means, start the overview always on the specified weekday.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 0 Denotes Sunday, 1 denotes Monday etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 When nil, always start on the current day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 :type '(choice (const :tag "Today" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (const :tag "First day of month" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (number :tag "Weekday No.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (defcustom org-agenda-ndays 7
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 "Number of days to include in overview display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 :group 'org-agenda
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-agenda-include-all-todo t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
527 "Non-nil means, the agenda will always contain all TODO entries.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 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
529 with a prefix argument.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 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
531 the entries for specific days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (defcustom org-agenda-include-diary nil
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
536 "If non-nil, include in the agenda entries from the Emacs Calendar's diary."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
540 (defcustom org-calendar-to-agenda-key [?c]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
541 "The key to be installed in `calendar-mode-map' for switching to the agenda.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
542 The command `org-calendar-goto-agenda' will be bound to this key. The
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
543 default is the character `c' because then`c' can be used to switch back and
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
544 force between agenda and calendar."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
545 :group 'org-agenda
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
546 :type 'sexp)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (defcustom org-agenda-sorting-strategy '(time-up category-keep priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 "Sorting structure for the agenda items of a single day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 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
551 if an entry should be listed before another entry. The following
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 symbols are recognized.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 time-up Put entries with time-of-day indications first, early first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 time-down Put entries with time-of-day indications first, late first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 category-keep Keep the default order of categories, corresponding to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 sequence in `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 category-up Sort alphabetically by category, A-Z.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 category-down Sort alphabetically by category, Z-A.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 priority-up Sort numerically by priority, high priority last.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 priority-down Sort numerically by priority, high priority first.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 The different possibilities will be tried in sequence, and testing stops
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 if one comparison returns a \"not-equal\". For example, the default
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 '(time-up category-keep priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 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
567 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
568 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
569 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
570 the sequence given in `org-agenda-files'. Within each category sort by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 priority.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 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
574 categories by priority."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (const time-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (const time-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (const category-keep)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (const category-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (const category-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (const priority-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (const priority-down))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
586 (defcustom org-agenda-prefix-format " %-12:c% s"
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
587 "Format specification for the prefix of items in the agenda buffer.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
588 This format works similar to a printf format, with the following meaning:
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
589
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
590 %c the category of the item, \"Diary\" for entries from the diary, or
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
591 as given by the CATEGORY keyword or derived from the file name.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
592 %t the time-of-day specification if one applies to the entry, in the
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
593 format HH:MM
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
594 %s Scheduling/Deadline information, a short string
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
595
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
596 In addition to the normal printf field modifiers like field width and
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
597 padding instructions, in this format you can also add an additional
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
598 punctuation or whitespace character just before the final format letter.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
599 This character will be appended to the field value if the value is not
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
600 empty. For example, the format \"%-12:c\" leads to \"Diary: \" if
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
601 the category is \"Diary\". If the category were be empty, no additional
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
602 colon would be interted.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
603
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
604 Including `%t' in the format string leads to a double time specification
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
605 because the headline/diary item will contain the time specification as
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
606 well. However, using `%t' in the format will result in a canonical 24
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
607 hour time specification at a consistent position in the prefix, while the
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
608 time specification in the headline/diary item may be at any position and in
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
609 various formats.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
610 Example:
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
611 (setq org-agenda-prefix-format \" %-12:c% t% s\")"
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
612 :type 'string
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
613 :group 'org-agenda)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
614
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
615 (defcustom org-timeline-prefix-format " % s"
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
616 "Like `org-agenda-prefix-format', but for the timeline of a single file."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
617 :type 'string
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
618 :group 'org-agenda)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
619
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
620 (defvar org-prefix-format-compiled nil
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
621 "The compiled version of `org-???-prefix-format'.")
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
622
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (defcustom org-sort-agenda-notime-is-late t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 "Non-nil means, items without time are considered late.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 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
626 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
627 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
628 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (defgroup org-structure nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 "Options concerning structure editing in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 :tag "Org Structure"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
636 (defcustom org-cycle-hook '(org-optimize-window-after-visibility-change)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
637 "Hook that is run after `org-cycle' has changed the buffer visibility.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
638 The function(s) in this hook must accept a single argument which indicates
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
639 the new state that was set by the most recent `org-cycle' command. The
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
640 argument is a symbol. After a global state change, it can have the values
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
641 `overview', `content', or `all'. After a local state change, it can have
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
642 the values `folded', `children', or `subtree'."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
643 :group 'org-structure
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
644 :type 'hook)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
645
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
646 (defcustom org-occur-hook '(org-first-headline-recenter)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
647 "Hook that is run after `org-occur' has constructed a sparse tree.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
648 This can be used to recenter the window to show as much of the structure
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
649 as possible."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
650 :group 'org-structure
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
651 :type 'hook)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
652
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (defcustom org-adapt-indentation t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 "Non-nil means, adapt indentation when promoting and demoting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 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
656 indentation is increased by one space in a demotion command, and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 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
658 body starts at column 0, indentation is not changed at all."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 :group 'org-structure
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (defcustom org-cycle-emulate-tab t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 "Where should `org-cycle' emulate TAB.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 nil Never
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 white Only in completely white lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 t Everywhere except in headlines"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 :group 'org-structure
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 :type '(choice (const :tag "Never" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (const :tag "Only in completely white lines" white)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (const :tag "Everywhere except in headlines" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (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
674 "Formats for `format-time-string' which are used for time stamps.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 It is not recommended to change this constant.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
677 (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
678 "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
679 When doing an `org-occur' it is useful to show the headline which
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
680 follows the match, even if they do not match the regexp. This makes it
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
681 easier to edit directly inside the sparse tree. However, if you use
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
682 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
683 unnecessary clutter."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
684 :group 'org-structure
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
685 :type 'boolean)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
686
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
687
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (defgroup org-link nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 "Options concerning links in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 :tag "Org Link"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (defcustom org-allow-space-in-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 "Non-nil means, file names in links may contain space characters.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
695 When nil, it becomes possible to put several links into a line.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
696 Note that in tables, a link never extends accross fields, so in a table
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
697 it is always possible to put several links into a line.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
698 Changing this varable requires a re-launch of Emacs of become effective."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (defcustom org-line-numbers-in-file-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 "Non-nil means, file links from `org-store-link' contain line numbers.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 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
705 by the command `org-open-at-point'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 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
707 negates this setting for the duration of the command."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (defcustom org-keep-stored-link-after-insertion nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 "Non-nil means, keep link in list for entire session.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 The command `org-store-link' adds a link pointing to the current
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
715 location to an internal list. These links accumulate during a session.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 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
717 Org-mode file (offering completion for all stored links). When this
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
718 option is nil, every link which has been inserted once using \\[org-insert-link]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 will be removed from the list, to make completing the unused links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 more efficient."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (defcustom org-link-frame-setup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 '((vm . vm-visit-folder-other-frame)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (gnus . gnus-other-frame)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (file . find-file-other-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 "Setup the frame configuration for following links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 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
730 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
731 set this up for the different types of links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 For VM, use any of
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
733 `vm-visit-folder'
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
734 `vm-visit-folder-other-frame'
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 For Gnus, use any of
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
736 `gnus'
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
737 `gnus-other-frame'
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 For FILE, use any of
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
739 `find-file'
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
740 `find-file-other-window'
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
741 `find-file-other-frame'
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 For the calendar, use the variable `calendar-setup'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 For BBDB, it is currently only possible to display the matches in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 another window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 :type '(list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (cons (const vm)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (const vm-visit-folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (const vm-visit-folder-other-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (const vm-visit-folder-other-frame)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (cons (const gnus)
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 gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 (const gnus-other-frame)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (cons (const file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (const find-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (const find-file-other-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (const find-file-other-frame)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (defcustom org-usenet-links-prefer-google nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 "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
764 When nil, Gnus will be used for such links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 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
766 negates this setting for the duration of the command."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (defcustom org-open-non-existing-files nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 "Non-nil means, `org-open-file' will open non-existing file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 When nil, an error will be generated."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 (defcustom org-confirm-shell-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 "Non-nil means, ask for confirmation before executing shell links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 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
779 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (defconst org-file-apps-defaults-linux
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 '((t . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 ("jpg" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 ("gif" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 ("ppm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 ("pgm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 ("pbm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 ("tif" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 ("png" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 ("ps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 ("ps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 ("eps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 ("eps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 ("dvi" . "xdvi %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 ("mpeg" . "plaympeg %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 ("mp3" . "plaympeg %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 ("fig" . "xfig %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 ("pdf" . "acroread %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 ("doc" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 ("ppt" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 ("pps" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 ("html" . "netscape -remote openURL(%s,new-window)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 ("htm" . "netscape -remote openURL(%s,new-window)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 ("xs" . "soffice %s"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 "Default file applications on a UNIX/LINUX system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (defconst org-file-apps-defaults-macosx
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 '((t . "open %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 ("ps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 ("ps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 ("eps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 ("eps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 ("dvi" . "xdvi %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 ("fig" . "xfig %s"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 "Default file applications on a MacOS X system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 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
819 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
820 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (defconst org-file-apps-defaults-windowsnt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 '((t . (w32-shell-execute "open" file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 "Default file applications on a Windows NT system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 The system \"open\" is used for most files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (defcustom org-file-apps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 '(
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 ("txt" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 ("tex" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 ("ltx" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 ("org" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 ("el" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 "External applications for opening `file:path' items in a document.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 Org-mode uses system defaults for different file types, but
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 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
839 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
840 and the corresponding command. Possible values for the command are:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 `emacs' The file will be visited by the current Emacs process.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 `default' Use the default application for this file type.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
843 string A command to be executed by a shell; %s will be replaced
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 by the path to the file.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
845 sexp A Lisp form which will be evaluated. The file path will
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
846 be available in the Lisp variable `file'.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 For more examples, see the system specific constants
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 `org-file-apps-defaults-macosx'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 `org-file-apps-defaults-windowsnt'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 `org-file-apps-defaults-linux'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (cons (string :tag "Extension")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 (choice :value ""
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 (const :tag "Visit with Emacs" 'emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 (const :tag "Use system default" 'default)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 (string :tag "Command")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 (sexp :tag "Lisp form")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (defgroup org-remember nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 "Options concerning interaction with remember.el."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 :tag "Org Remember"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 :group 'org)
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 (defcustom org-directory "~/org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 "Directory with org files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 This directory will be used as default to prompt for org files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 Used by the hooks for remember.el."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 :type 'directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (defcustom org-default-notes-file "~/.notes"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 "Default target for storing notes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 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
876 the value of `remember-data-file'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (const :tag "Default from remember-data-file" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (defcustom org-reverse-note-order nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 "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
884 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
885 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 (const :tag "Reverse always" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 (const :tag "Reverse never" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 (repeat :tag "By file name regexp"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (cons regexp boolean))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (defgroup org-table nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 "Options concerning tables in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 :tag "Org Table"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
897 (defcustom org-enable-table-editor 'optimized
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 "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
899 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
900
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
901 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
902 do the following
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
903 - 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
904 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
905 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
906 - 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
907 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
908 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
909 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
910 `delete-char', and `backward-delete-char' in Org-mode buffers, with a
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
911 slight (in fact: unnoticeable) speed impact for normal typing. Org-mode is
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
912 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
913 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
914
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
915 If you would like to use the optimized version in Org-mode, but the
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
916 un-optimized version in OrgTbl-mode, see the variable `orgtbl-optimized'.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
917
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
918 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
919 but in order to toggle optimization, a restart is required."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 :group 'org-table
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
921 :type '(choice
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
922 (const :tag "off" nil)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
923 (const :tag "on" t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
924 (const :tag "on, optimized" optimized)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (defcustom org-table-default-size "5x2"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 "The default size for newly created tables, Columns x Rows."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 :group 'org-table
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
929 :type 'string)
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-automatic-realign t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 "Non-nil means, automatically re-align table when pressing TAB or RETURN.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 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
934 removal/insertion."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 (defcustom org-table-spaces-around-separators '(1 . 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 "The number of spaces to be placed before and after separators."
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 '(cons (number :tag "Before \"|\"") (number :tag " After \"|\"")))
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-invisible-separators '(1 . 2)
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 This option applies when the column separators have been made invisible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\"")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (defcustom org-table-number-regexp "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*$"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 "Regular expression for recognizing numbers in table columns.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 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
952 right. If not, it will be aligned to the left.
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 The default value of this option is a regular expression which allows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 anything which looks remotely like a number as used in scientific
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 context. For example, all of the following will be considered a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 number:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 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
959
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 Other options offered by the customize interface are more restrictive."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 (const :tag "Positive Integers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 "^[0-9]+$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 (const :tag "Integers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 "^[-+]?[0-9]+$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 (const :tag "Floating Point Numbers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.[0-9]*\\)$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (const :tag "Floating Point Number or Integer"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 (const :tag "Exponential, Floating point, Integer"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 "^[-+]?[0-9.]+\\([eEdD][-+0-9]+\\)?$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 (const :tag "Very General Number-Like"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 (string :tag "Regexp:")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 (defcustom org-table-number-fraction 0.5
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 "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
979 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
980 fraction of fields is matched by `org-table-number-fraction',
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 alignment to the right border applies."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (defcustom org-export-highlight-first-table-line t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 "Non-nil means, highlight the first table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 In HTML export, this means use <th> instead of <td>.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 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
989 In Org-mode tables, all lines before the first horizontal separator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 line will be formatted with <th> tags."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
994 (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
995 "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
996 :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
997 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
998
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (defcustom org-table-tab-recognizes-table.el t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 "Non-nil means, TAB will automatically notice a table.el table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 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
1002 calls `table-recognize-table'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 (defcustom org-export-prefer-native-exporter-for-tables nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 "Non-nil means, always export tables created with table.el natively.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 Natively means, use the HTML code generator in table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 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
1010 the table does not use row- or column-spanning). This has the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 advantage, that the automatic HTML conversions for math symbols and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 sub/superscripts can be applied. Org-mode's HTML generator is also
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 much faster."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 (defcustom org-enable-fixed-width-editor t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 "Non-nil means, lines starting with \":\" are treated as fixed-width.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 This currently only means, they are never auto-wrapped.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 When nil, such lines will be treated like ordinary lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (defgroup org-export nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 "Options for exporting org-listings."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 :tag "Org Export"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 :group 'org)
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 (defcustom org-export-language-setup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 '(("en" "Author" "Date" "Table of Contents")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 ("da" "Ophavsmand" "Dato" "Indhold")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 ("de" "Autor" "Datum" "Inhaltsverzeichnis")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 ("es" "Autor" "Fecha" "\xccndice")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 ("fr" "Auteur" "Date" "Table des Mati\xe8res")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 ("it" "Autore" "Data" "Indice")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 ("nl" "Auteur" "Datum" "Inhoudsopgave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 "Terms used in export text, translated to different languages.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 Use the variable `org-export-default-language' to set the language,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 or use the +OPTION lines for a per-file setting."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 (string :tag "HTML language tag")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 (string :tag "Author")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 (string :tag "Date")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 (string :tag "Table of Contents"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 (defcustom org-export-default-language "en"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 "The default language of HTML export, as a string.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 This should have an association in `org-export-language-setup'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 (defcustom org-export-headline-levels 3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 "The last level which is still exported as a headline.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 Inferior levels will produce itemize lists when exported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 Note that a numeric prefix argument to an exporter function overrides
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 this setting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 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
1063 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 (defcustom org-export-with-section-numbers t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 "Non-nil means, add section numbers to headlines when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 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
1070 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 (defcustom org-export-with-toc t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 "Non-nil means, create a table of contents in exported files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 The TOC contains headlines with levels up to`org-export-headline-levels'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 Headlines which contain any TODO items will be marked with \"(*)\" in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 ASCII export, and with red color in HTML output.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 In HTML output, the TOC will be clickable.
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 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
1083 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 (defcustom org-export-preserve-breaks nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 "Non-nil means, preserve all line breaks when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 Normally, in HTML output paragraphs will be reformatted. In ASCII
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 export, line breaks will always be preserved, regardless of this variable.
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 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
1092 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 (defcustom org-export-html-inline-images t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 "Non-nil means, inline images into exported HTML pages.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 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
1098 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
1099 you will have to move the image and maybe change the link."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 (defcustom org-export-html-expand t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 "Non-nil means, for HTML export, treat @<...> as HTML tag.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 When nil, these tags will be exported as plain text and therefore
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 not be interpreted by a browser.
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 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
1109 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 (defcustom org-export-with-fixed-width t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 "Non-nil means, lines starting with \":\" will be in fixed width font.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1114 This can be used to have pre-formatted text, fragments of code etc. For
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 : ;; Some Lisp examples
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 : (while (defc cnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 : (ding))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 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
1120 has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 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
1123 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 (defcustom org-export-with-tables t
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
1127 "If non-nil, lines starting with \"|\" define a table.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 For example:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 | Name | Address | Birthday |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 |-------------+----------+-----------|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 | Arthur Dent | England | 29.2.2100 |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 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
1137 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (defcustom org-export-html-table-tag
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 "<table border=1 cellspacing=0 cellpadding=6>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 "The HTML tag used to start a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 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
1144 borders and spacing."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 (defcustom org-export-with-emphasize t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1149 "Non-nil means, interpret *word*, /word/, and _word_ as emphasized text.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 If the export target supports emphasizing text, the word will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 typeset in bold, italic, or underlined, respectively. Works only for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 single words, but you can say: I *really* *mean* *this*.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 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
1156 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (defcustom org-match-sexp-depth 3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 "Number of stacked braces for sub/superscript matching.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 This has to be set before loading org.el to be effective."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 :type 'integer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 ;; FIXME: Should () parens be removed as well in sub/superscripts?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 (defcustom org-export-with-sub-superscripts t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1167 "Non-nil means, interpret \"_\" and \"^\" for export.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 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
1169 superscripts. Several characters after \"_\" or \"^\" will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 considered as a single item - so grouping with {} is normally not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 needed. For example, the following things will be parsed as single
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 sub- or superscripts.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 10^24 or 10^tau several digits will be considered 1 item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 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
1176 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
1177 terminated by almost any nonword/nondigit char.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 x_{i^2} or x^(2-i) braces or parenthesis do grouping.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 Still, ambiguity is possible - so when in doubt use {} to enclose the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 sub/superscript.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 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
1185 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 (defcustom org-export-with-TeX-macros t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1189 "Non-nil means, interpret simple TeX-like macros when exporting.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 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
1192 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
1193 names in HTML export, see the constant `org-html-entities'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 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
1197 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 (defcustom org-export-html-with-timestamp nil
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1201 "If non-nil, write `org-export-html-html-helper-timestamp'
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 into the exported html text. Otherwise, the buffer will just be saved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 to a file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 (defcustom org-export-html-html-helper-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 "<br><br><hr><p><!-- hhmts start --> <!-- hhmts end -->\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 (defcustom org-export-ascii-show-new-buffer t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 "Non-nil means, popup buffer containing the exported ASCII text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 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
1216 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 (defcustom org-export-html-show-new-buffer nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 "Non-nil means, popup buffer containing the exported html text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 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
1222 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 (defgroup org-faces nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 "Faces for highlighting in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 :tag "Org Faces"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 :group 'org)
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 (defface org-level-1-face ;; font-lock-function-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 "Face used for level 1 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 (defface org-level-2-face ;; font-lock-variable-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 '((((type tty) (class color)) (:foreground "yellow" :weight light))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 (((class color) (background light)) (:foreground "DarkGoldenrod"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 (((class color) (background dark)) (:foreground "LightGoldenrod"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 "Face used for level 2 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (defface org-level-3-face ;; font-lock-keyword-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (((class color) (background light)) (:foreground "Purple"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 (((class color) (background dark)) (:foreground "Cyan"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 "Face used for level 3 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 (defface org-level-4-face ;; font-lock-comment-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 '((((type tty pc) (class color) (background light)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 (((class color) (background light)) (:foreground "Firebrick"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (((class color) (background dark)) (:foreground "chocolate1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 "Face used for level 4 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 (defface org-level-5-face ;; font-lock-type-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 (((class color) (background light)) (:foreground "ForestGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 (((class color) (background dark)) (:foreground "PaleGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 "Face used for level 5 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 (defface org-level-6-face ;; font-lock-constant-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 '((((type tty) (class color)) (:foreground "magenta"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 (((class color) (background light)) (:foreground "CadetBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 (((class color) (background dark)) (:foreground "Aquamarine"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 "Face used for level 6 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (defface org-level-7-face ;; font-lock-builtin-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 '((((type tty) (class color)) (:foreground "blue" :weight light))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 (((class color) (background light)) (:foreground "Orchid"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 (((class color) (background dark)) (:foreground "LightSteelBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 "Face used for level 7 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1288 (defface org-level-8-face ;; font-lock-string-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 (((class color) (background light)) (:foreground "RosyBrown"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 (((class color) (background dark)) (:foreground "LightSalmon"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (t (:italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 "Face used for level 8 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (defface org-warning-face ;; font-lock-warning-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 '((((type tty) (class color)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 (((class color) (background light)) (:foreground "Red" :bold t))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1299 (((class color) (background dark)) (:foreground "Red1" :bold t))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1300 ; (((class color) (background dark)) (:foreground "Pink" :bold t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 (t (:inverse-video t :bold t)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1302 "Face for deadlines and TODO keywords."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1305 (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
1306 "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
1307 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
1308 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
1309 `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
1310 :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
1311 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1312
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1313 (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
1314 '((((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
1315 (((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
1316 (((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
1317 (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
1318 "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
1319 `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
1320 :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
1321
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1322 ;; Inheritance does not yet work for xemacs. So we just copy...
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 (defface org-deadline-announce-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 "Face for upcoming deadlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (defface org-scheduled-today-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 (((class color) (background light)) (:foreground "DarkGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 (((class color) (background dark)) (:foreground "PaleGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 "Face for items scheduled for a certain day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (defface org-scheduled-previously-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 '((((type tty pc) (class color) (background light)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 (((class color) (background light)) (:foreground "Firebrick"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 (((class color) (background dark)) (:foreground "chocolate1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 "Face for items scheduled previously, and not yet done."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (defface org-link-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (((class color) (background light)) (:foreground "Purple"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352 (((class color) (background dark)) (:foreground "Cyan"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 "Face for links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (defface org-done-face ;; font-lock-type-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 (((class color) (background dark)) (:foreground "PaleGreen" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 "Face used for DONE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 (defface org-table-face ;; font-lock-function-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 "Face used for tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (defvar org-level-faces
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 '(
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 org-level-1-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 org-level-2-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 org-level-3-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 org-level-4-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 org-level-5-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 org-level-6-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 org-level-7-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 org-level-8-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 (defvar org-n-levels (length org-level-faces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 ;; Tell the compiler about dynamically scoped variables,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 ;; and variables from other packages
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 (eval-when-compile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 (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
1390 (defvar original-date)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 (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
1392 (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
1393 (defvar orgtbl-mode-menu)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (defvar org-html-entities)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 (defvar org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 (defvar org-cursor-color)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 (defvar org-time-was-given)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 (defvar org-ts-what)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1399 (defvar mark-active)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (defvar timecnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 (defvar levels-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (defvar title)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 (defvar author)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 (defvar email)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (defvar text)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 (defvar entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 (defvar date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 (defvar language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (defvar options)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 (defvar ans1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 (defvar ans2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 (defvar starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (defvar include-all-loc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 (defvar vm-message-pointer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (defvar vm-folder-directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (defvar wl-summary-buffer-elmo-folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 (defvar wl-summary-buffer-folder-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 (defvar gnus-group-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (defvar gnus-article-current)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (defvar w3m-current-url)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (defvar org-selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 (defvar calendar-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (defvar remember-save-after-remembering)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (defvar remember-data-file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 ;;; Define the mode
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 (defvar org-mode-map (copy-keymap outline-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 "Keymap for Org-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-struct-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 (defvar org-org-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1435 ;; We use a before-change function to check if a table might need
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1436 ;; an update.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1437 (defvar org-table-may-need-update t
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1438 "Indicates of a table might need an update.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1439 This variable is set by `org-before-change-function'. `org-table-align'
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1440 sets it back to nil.")
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1441
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1442 (defvar org-mode-hook nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1443 (defvar org-inhibit-startup nil) ; Dynamically-scoped param.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1444
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1445
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 (defun org-mode (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 "Outline-based notes management and organizer, alias
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 \"Carstens outline-mode for keeping track of everything.\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 Org-mode develops organizational tasks around a NOTES file which
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 contains information about projects as plain text. Org-mode is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 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
1454 of large files well structured. It supports ToDo items, deadlines and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 time stamps, which magically appear in the diary listing of the Emacs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 calendar. Tables are easily created with a built-in table editor.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 Plain text URL-like links connect to websites, emails (VM), Usenet
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 messages (Gnus), BBDB entries, and any files related to the project.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 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
1460 can be exported as a well-structured ASCII or HTML file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1462 The following commands are available:
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 \\{org-mode-map}"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 (outline-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (setq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 (setq mode-name "Org")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 (use-local-map org-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 (easy-menu-add org-org-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (setq outline-regexp "\\*+")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (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
1474 (org-set-regexps-and-options)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (set (make-local-variable 'font-lock-unfontify-region-function)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 'org-unfontify-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 ;; 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
1478 (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
1479 (make-local-hook 'before-change-functions) ;; needed for XEmacs
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (add-hook 'before-change-functions 'org-before-change-function nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 'local)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 (set (make-local-variable 'auto-fill-inhibit-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 (concat "\\*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (if (or org-enable-table-editor org-enable-fixed-width-editor)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 "\\|[ \t]*["
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (if org-enable-table-editor "|" "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (if org-enable-fixed-width-editor ":" "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 "]"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 ;; Hook, and startup actions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 (if (or arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (and org-insert-mode-line-in-empty-file
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1494 (interactive-p)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 (= (point-min) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 (insert " -*- mode: org -*-\n\n")))
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
1499 (run-hooks 'org-mode-hook) ;FIXME: Should be run-mode-hooks.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1500 (unless org-inhibit-startup
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1501 (if org-startup-with-deadline-check
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1502 (call-interactively 'org-check-deadlines)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1503 (cond
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1504 ((eq org-startup-folded t)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1505 (org-cycle '(4)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1506 ((eq org-startup-folded 'content)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1507 (let ((this-command 'org-cycle) (last-command 'org-cycle))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1508 (org-cycle '(4)) (org-cycle '(4))))))))
58792
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 ;;; Font-Lock stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (defvar org-mouse-map (make-sparse-keymap))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (define-key org-mouse-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (define-key org-mouse-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 (require 'font-lock)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1520 (defconst org-non-link-chars "\t\n\r|")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 (defconst org-link-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 (if org-allow-space-in-links
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1523 (concat
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1524 "\\(https?\\|ftp\\|mailto|\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^" org-non-link-chars "]+[^ " org-non-link-chars "]\\)")
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1525 (concat
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1526 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ " org-non-link-chars "]+\\)")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 "Regular expression for matching links.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 (defconst org-ts-lengths
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 (cons (length (format-time-string (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (length (format-time-string (cdr org-time-stamp-formats))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 "This holds the lengths of the two different time formats.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (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
1534 "Regular expression for fast time stamp matching.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (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
1536 "Regular expression matching time strings for analysis.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 ">")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 "Regular expression matching time stamps, with groups.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 "Regular expression matching a time stamp range.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 org-ts-regexp "\\)?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 "Regular expression matching a time stamp or time stamp range.")
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 (defun org-activate-links (limit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 "Run through the buffer and add overlays to links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 (if (re-search-forward org-link-regexp limit t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (add-text-properties (match-beginning 0) (match-end 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 (list 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 'keymap org-mouse-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 (defun org-activate-dates (limit)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1555 "Run through the buffer and add overlays to dates."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 (if (re-search-forward org-tsr-regexp limit t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (add-text-properties (match-beginning 0) (match-end 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 (list 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 'keymap org-mouse-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 (defun org-font-lock-level ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 (- (match-end 0) (match-beginning 0))))
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
1568
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1569 (defvar org-font-lock-keywords nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1570
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 (defun org-set-font-lock-defaults ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 (let ((org-font-lock-extra-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 '(org-activate-links (0 'org-link-face))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 '(org-activate-dates (0 'org-link-face))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1576 (list (concat "^\\*+[ \t]*" org-not-done-regexp)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1577 '(1 'org-warning-face t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 (list (concat "\\[#[A-Z]\\]") '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 (list (concat "\\<" org-deadline-string) '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 (list (concat "\\<" org-scheduled-string) '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 ;; (3 'bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 ;; (3 'italic))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 ;; (3 'underline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 '("\\<FIXME\\>" (0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 '(1 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 '("^#.*" (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
1591 (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
1592 (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
1593 '(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
1594 (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
1595 '(1 'org-done-face t)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597 (1 'org-table-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 '("^[ \t]*\\(:.*\\)" (1 'org-table-face t)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 (set (make-local-variable 'org-font-lock-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 (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
1602 ; on XEmacs if noutline is ever ported
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 '((eval . (list "^\\(\\*+\\).*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 0 '(nth
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 (% (- (match-end 1) (match-beginning 1) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 org-n-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 org-level-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 nil t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 '(("^\\(\\(\\*+\\)[^\r\n]*\\)[\n\r]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (1 (nth (% (- (match-end 2) (match-beginning 2) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 org-n-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 org-level-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 nil t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 org-font-lock-extra-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 (set (make-local-variable 'font-lock-defaults)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 '(org-font-lock-keywords t nil nil backward-paragraph))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 (kill-local-variable 'font-lock-keywords) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (defun org-unfontify-region (beg end &optional maybe_loudly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 "Remove fontification and activation overlays from links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 (font-lock-default-unfontify-region beg end)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1622 (let* ((buffer-undo-list t)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623 (inhibit-read-only t) (inhibit-point-motion-hooks t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 (inhibit-modification-hooks t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 deactivate-mark buffer-file-name buffer-file-truename)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 (remove-text-properties beg end '(mouse-face nil keymap nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 ;;; Visibility cycling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 (defvar org-cycle-global-status nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 (defvar org-cycle-subtree-status nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 (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
1633 "Visibility cycling for Org-mode.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 - When this function is called with a prefix argument, rotate the entire
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 buffer through 3 states (global cycling)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 1. OVERVIEW: Show only top-level headlines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 2. CONTENTS: Show all headlines of all levels, but no body text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 3. SHOW ALL: Show everything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641 - 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
1642 by this line through 3 different states (local cycling)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643 1. FOLDED: Only the main headline is shown.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1644 2. CHILDREN: The main headline and the direct children are shown. From
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 this state, you can move to one of the children and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646 zoom in further.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647 3. SUBTREE: Show the entire subtree, including body text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1648
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1649 - 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
1650 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
1651
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1652 - When point is not at the beginning of a headline, execute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1653 `indent-relative', like TAB normally does. See the option
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1654 `org-cycle-emulate-tab' for details.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656 - 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
1657 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
1658 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1660 (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
1661 (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
1662 ;; special case: use global cycling
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 (setq arg t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 ((org-at-table-p 'any)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 ;; Enter the table or move to the next field in the table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (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
1670 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1671 (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
1672 (org-table-next-field))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1674 ((eq arg t) ;; Global cycling
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 (eq org-cycle-global-status 'overview))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 ;; We just created the overview - now do table of contents
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 ;; This can be slow in very large buffers, so indicate action
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 (message "CONTENTS...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 ;; Visit all headings and show their offspring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 (while (and (progn (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687 (outline-previous-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 (error (goto-char (point-min))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 (show-branches)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 (if (bobp) (throw 'exit nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 (message "CONTENTS...done"))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1694 (setq org-cycle-global-status 'contents)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1695 (run-hook-with-args 'org-cycle-hook 'contents))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1696
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 (eq org-cycle-global-status 'contents))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 ;; We just showed the table of contents - now show everything
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 (show-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (message "SHOW ALL")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1702 (setq org-cycle-global-status 'all)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1703 (run-hook-with-args 'org-cycle-hook 'all))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1704
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 ;; Default action: go to overview
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 (hide-sublevels 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 (message "OVERVIEW")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1709 (setq org-cycle-global-status 'overview)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1710 (run-hook-with-args 'org-cycle-hook 'overview))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1712 ((integerp arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1713 ;; 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
1714 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1715 (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
1716 (outline-up-heading arg)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1717 (org-show-subtree)))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1718
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 ((save-excursion (beginning-of-line 1) (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 ;; At a heading: rotate between three different views
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 (org-back-to-heading)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1722 (let ((goal-column 0) eoh eol eos)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 ;; First, some boundaries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 (save-excursion
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1725 (org-back-to-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 (while (and (not (eobp)) ;; this is like `next-line'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 (get-char-property (1- (point)) 'invisible))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 (beginning-of-line 2)) (setq eol (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 (outline-end-of-heading) (setq eoh (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 (outline-end-of-subtree) (setq eos (point))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1733 (outline-next-heading))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 ;; Find out what to do next and set `this-command'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 ((= eos eoh)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 ;; Nothing is hidden behind this heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 (message "EMPTY ENTRY")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739 (setq org-cycle-subtree-status nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 ((>= eol eos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 ;; Entire subtree is hidden in one line: open it
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1742 (org-show-entry)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 (show-children)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 (message "CHILDREN")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1745 (setq org-cycle-subtree-status 'children)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1746 (run-hook-with-args 'org-cycle-hook 'children))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1747 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1748 (eq org-cycle-subtree-status 'children))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 ;; We just showed the children, now show everything.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1750 (org-show-subtree)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 (message "SUBTREE")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1752 (setq org-cycle-subtree-status 'subtree)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1753 (run-hook-with-args 'org-cycle-hook 'subtree))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 ;; Default action: hide the subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (hide-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (message "FOLDED")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1758 (setq org-cycle-subtree-status 'folded)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1759 (run-hook-with-args 'org-cycle-hook 'folded)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 ;; TAB emulation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 (buffer-read-only (org-back-to-heading))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 ((if (and (eq org-cycle-emulate-tab 'white)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (save-excursion (beginning-of-line 1) (looking-at "[ \t]+$")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 (eq org-cycle-emulate-tab t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 (if (and (looking-at "[ \n\r\t]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 (string-match "^[ \t]*$" (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 (point-at-bol) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (and (looking-at "[ \t]+") (replace-match ""))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 (indent-relative))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 (t (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 (org-cycle)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1779 (defun org-optimize-window-after-visibility-change (state)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1780 "Adjust the window after a change in outline visibility.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1781 This function is the default value of the hook `org-cycle-hook'."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1782 (cond
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1783 ((eq state 'overview) (org-first-headline-recenter 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1784 ((eq state 'content) nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1785 ((eq state 'all) nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1786 ((eq state 'folded) nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1787 ((eq state 'children) (or (org-subtree-end-visible-p) (recenter 1)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1788 ((eq state 'subtree) (or (org-subtree-end-visible-p) (recenter 1)))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1789
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1790 (defun org-subtree-end-visible-p ()
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1791 "Is the end of the current subtree visible?"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1792 (pos-visible-in-window-p
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1793 (save-excursion (outline-end-of-subtree) (point))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1794
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1795 (defun org-first-headline-recenter (&optional N)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1796 "Move cursor to the first headline and recenter the headline.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1797 Optional argument N means, put the headline into the Nth line of the window."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1798 (goto-char (point-min))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1799 (when (re-search-forward (concat "^" outline-regexp) nil t)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1800 (beginning-of-line)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1801 (recenter (prefix-numeric-value N))))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1802
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (defvar org-goto-window-configuration nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 (defvar org-goto-marker nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (defvar org-goto-map (make-sparse-keymap))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (let ((cmds '(isearch-forward isearch-backward)) cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (while (setq cmd (pop cmds))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 (substitute-key-definition cmd cmd org-goto-map global-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (define-key org-goto-map [(return)] 'org-goto-ret)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810 (define-key org-goto-map [(left)] 'org-goto-left)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 (define-key org-goto-map [(right)] 'org-goto-right)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 (define-key org-goto-map [(?q)] 'org-goto-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 (define-key org-goto-map [(control ?g)] 'org-goto-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 (define-key org-goto-map [(tab)] 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815 (define-key org-goto-map [(down)] 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (define-key org-goto-map [(up)] 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 (define-key org-goto-map "n" 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 (define-key org-goto-map "p" 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 (define-key org-goto-map "f" 'outline-forward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 (define-key org-goto-map "b" 'outline-backward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 (define-key org-goto-map "u" 'outline-up-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 (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
1823 (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
1824 (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
1825 (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
1826 (define-key org-goto-map "\C-c\C-u" 'outline-up-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (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
1829
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 (defconst org-goto-help
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 "Select a location to jump to, press RET
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 \[Up]/[Down]=next/prev headline TAB=cycle visibility RET=select [Q]uit")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 (defun org-goto ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 "Go to a different location of the document, keeping current visibility.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 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
1838 is often to fold the entire buffer and then dive into the tree. This
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1839 method has the disadvantage, that the previous location will be folded,
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1840 which may not be what you want.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 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
1843 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
1844 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
1845 original buffer in which the visibility is still unchanged. It then jumps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 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
1847 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 (let* ((org-goto-start-pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 (selected-point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 (org-get-location (current-buffer) org-goto-help)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 (if selected-point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (goto-char selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (if (org-invisible-p) (org-show-hierarchy-above)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 (error "Quit"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 (defun org-get-location (buf help)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 "Let the user select a location in the Org-mode buffer BUF.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 This function uses a recursive edit. It returns the selected position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1860 or nil."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1861 (let (org-selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1862 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1863 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1864 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1865 (switch-to-buffer (get-buffer-create "*org-goto*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1866 (with-output-to-temp-buffer "*Help*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1867 (princ help))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1869 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1871 (insert-buffer buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1872 (let ((org-startup-truncated t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1873 (org-startup-folded t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874 (org-startup-with-deadline-check nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1875 (org-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876 (setq buffer-read-only t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1877 (if (boundp 'org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 (goto-char org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 (goto-char (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1880 (org-beginning-of-line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 (message "Select location and press RET")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882 ;; now we make sure that during selection, ony very few keys work
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 ;; and that it is impossible to switch to another window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884 (let ((gm (current-global-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (overriding-local-map org-goto-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1886 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888 (use-global-map org-goto-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889 (recursive-edit))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1890 (use-global-map gm)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1891 (kill-buffer "*org-goto*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 org-selected-point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 ;; 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
1895 (defun org-goto-ret (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 current-prefix-arg arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1902 (defun org-goto-left ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1903 "Finish org-goto by going to the new location."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1904 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1905 (if (org-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 current-prefix-arg (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911 (error "Not on a heading")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1913 (defun org-goto-right ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 "Finish org-goto by going to the new location."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1915 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 (if (org-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 (outline-end-of-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 (or (eobp) (forward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 current-prefix-arg (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (error "Not on a heading")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 (defun org-goto-quit ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 "Finish org-goto without cursor motion."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 (setq org-selected-point nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 ;;; Promotion, Demotion, Inserting new headlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 (defvar org-ignore-region nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1934 "To temporarily disable the active region.")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1935
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1936 (defun org-insert-heading ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 "Insert a new heading with same depth at point."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1938 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 (let* ((head (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 (error (outline-next-heading)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 (prog1 (match-string 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944 (funcall outline-level)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 (unless (bolp) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 (insert head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 (unless (eolp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 (save-excursion (newline-and-indent)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 (unless (equal (char-before) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (insert " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (run-hooks 'org-insert-heading-hook)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1953 (defun org-insert-todo-heading (arg)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1954 "Insert a new heading with the same level and TODO state as current heading.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1955 If the heading has no TODO state, or if the state is DONE, use the first
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1956 state (TODO by default). Also with prefix arg, force first state."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1957 (interactive "P")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1958 (org-insert-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1959 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1960 (org-back-to-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1961 (outline-previous-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1962 (looking-at org-todo-line-regexp))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1963 (if (or arg
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1964 (not (match-beginning 2))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1965 (equal (match-string 2) org-done-string))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1966 (insert (car org-todo-keywords) " ")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1967 (insert (match-string 2) " ")))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1968
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1969 (defun org-promote-subtree ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 "Promote the entire subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 See also `org-promote'."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1972 (interactive)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1973 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1974 (org-map-tree 'org-promote)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1975
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1976 (defun org-demote-subtree ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 "Demote the entire subtree. See `org-demote'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 See also `org-promote'."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1979 (interactive)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1980 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1981 (org-map-tree 'org-demote)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1982
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1983 (defun org-do-promote ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 "Promote the current heading higher up the tree.
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
1985 If the region is active in `transient-mark-mode', promote all headings
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 in the region."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1987 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (org-map-region 'org-promote (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 (org-promote)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 (org-fix-position-after-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1994 (defun org-do-demote ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 "Demote the current heading lower down the tree.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1996 If the region is active in `transient-mark-mode', demote all headings
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1997 in the region."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
1998 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 (org-map-region 'org-demote (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2002 (org-demote)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2003 (org-fix-position-after-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 (defun org-fix-position-after-promote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 "Make sure that after pro/demotion cursor position is right."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 (and (equal (char-after) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2008 (equal (char-before) ?*)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009 (forward-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (defun org-promote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012 "Promote the current heading higher up the tree.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2013 If the region is active in `transient-mark-mode', promote all headings
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2015 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 (let* ((level (save-match-data (funcall outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017 (up-head (make-string (1- level) ?*)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019 (replace-match up-head nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 (org-fixup-indentation "^ " "" "^ ?\\S-"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 (defun org-demote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024 "Demote the current heading lower down the tree.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2025 If the region is active in `transient-mark-mode', demote all headings
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2027 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 (let* ((level (save-match-data (funcall outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 (down-head (make-string (1+ level) ?*)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030 (replace-match down-head nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 (org-fixup-indentation "^ " " " "^\\S-"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 (defun org-map-tree (fun)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 "Call FUN for every heading underneath the current one."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2036 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 (let ((level (outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 (funcall fun)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040 (while (and (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 (> (funcall outline-level) level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2043 (not (eobp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044 (funcall fun)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 (defun org-map-region (fun beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2047 "Call FUN for every heading between BEG and END."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (let ((org-ignore-region t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2050 (setq end (copy-marker end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2051 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052 ;; (if (fboundp 'deactivate-mark) (deactivate-mark))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053 ;; (if (fboundp 'zmacs-deactivate-region) (zmacs-deactivate-region))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 (if (and (re-search-forward (concat "^" outline-regexp) nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2056 (funcall fun))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 (while (and (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2058 (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059 (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 (not (eobp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2061 (funcall fun)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2062
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2063 (defun org-fixup-indentation (from to prohibit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2064 "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
2065 However, if the regexp PROHIBIT matches at all, don't do anything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 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
2067 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
2068 is changed at all."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 (let ((end (save-excursion (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 (point-marker))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (unless (save-excursion (re-search-forward prohibit end t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2073 (while (re-search-forward from end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2074 (replace-match to)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 (beginning-of-line 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2076 (move-marker end nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2077
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2078 ;;; Vertical tree motion, cutting and pasting of subtrees
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2079
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 (defun org-move-subtree-up (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 "Move the current subtree up past ARG headlines of the same level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2083 (org-move-subtree-down (- (prefix-numeric-value arg))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2084
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2085 (defun org-move-subtree-down (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2086 "Move the current subtree down past ARG headlines of the same level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2087 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2088 (setq arg (prefix-numeric-value arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2089 (let ((movfunc (if (> arg 0) 'outline-get-next-sibling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2090 'outline-get-last-sibling))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 (ins-point (make-marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 (cnt (abs arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2093 beg end txt folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2094 ;; Select the tree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2096 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2097 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2098 (save-excursion (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 (setq folded (org-invisible-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 (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
2101 (outline-next-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2103 ;; Find insertion point, with error handling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2104 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2105 (while (> cnt 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 (or (and (funcall movfunc) (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107 (progn (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 (error "Cannot move past superior level or buffer limit")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 (setq cnt (1- cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 (if (> arg 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 ;; Moving forward - still need to move over subtree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 (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
2113 (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
2114 (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
2115 (bolp)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2116 (newline))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (move-marker ins-point (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118 (setq txt (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (goto-char ins-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 (if folded (hide-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (move-marker ins-point nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 (defvar org-subtree-clip ""
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 "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
2127 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
2128 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
2129
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 (defvar org-subtree-clip-folded nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2131 "Was the last copied subtree folded?
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 This is used to fold the tree back after pasting.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2133
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2134 (defun org-cut-subtree ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 "Cut the current subtree into the clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 This is a short-hand for marking the subtree and then cutting it."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2137 (interactive)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2138 (org-copy-subtree 'cut))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2139
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2140 (defun org-copy-subtree (&optional cut)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 "Cut the current subtree into the clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 This is a short-hand for marking the subtree and then copying it.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2143 If CUT is non nil, actually cut the subtree."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2144 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (let (beg end folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2147 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 (save-excursion (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (setq folded (org-invisible-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 (outline-end-of-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (if (equal (char-after) ?\n) (forward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 (when (> end beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 (setq org-subtree-clip-folded folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2157 (if cut (kill-region beg end) (copy-region-as-kill beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 (setq org-subtree-clip (current-kill 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159 (message "%s: Subtree with %d characters"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 (if cut "Cut" "Copied")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 (length org-subtree-clip)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 (defun org-paste-subtree (&optional level tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 "Paste the clipboard as a subtree, with modification of headline level.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 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
2166 level. By default, the new level is derived from the visible headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 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
2168 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
2169 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
2170 This makes sure that the subtree remains an independent subtree and does
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2171 not swallow low level entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2172
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2173 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
2174 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
2175 cursor is after \"*****\", then the tree will be shifted to level 5.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177 If you want to insert the tree as is, just use \\[yank].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 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
2180 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181 (unless (org-kill-is-subtree-p tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184 "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
2185 (let* ((txt (or tree (current-kill 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2186 (^re (concat "^\\(" outline-regexp "\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187 (re (concat "\\(" outline-regexp "\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188 (^re_ (concat "\\(" outline-regexp "\\)[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 (old-level (if (string-match ^re txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 (force-level (cond (level (prefix-numeric-value level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 ((string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 ^re_ (buffer-substring (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 (t nil)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2198 (previous-level (save-excursion
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199 (outline-previous-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200 (if (looking-at re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 (next-level (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 (outline-next-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 (if (looking-at re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 1)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2208 (new-level (or force-level (max previous-level next-level)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 (shift (if (or (= old-level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 (= new-level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 (= old-level new-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2212 0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2213 (- new-level old-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2214 (shift1 shift)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 (delta (if (> shift 0) -1 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 (func (if (> shift 0) 'org-demote 'org-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2217 beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 ;; Remove the forces level indicator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 (if force-level
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 (delete-region (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 ;; Make sure we start at the beginning of an empty line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 (if (not (bolp)) (insert "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 (if (not (looking-at "[ \t]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 (progn (insert "\n") (backward-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225 ;; Paste
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230 ;; Shift if necessary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2231 (if (= shift 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2232 (message "Pasted at level %d, without shift" new-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 (narrow-to-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 (while (not (= shift 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 (org-map-region func (point-min) (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237 (setq shift (+ delta shift)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2239 (message "Pasted at level %d, with shift by %d levels"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 new-level shift1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241 (if (and (eq org-subtree-clip (current-kill 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2242 org-subtree-clip-folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2243 ;; The tree was folded before it was killed/copied
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 (hide-subtree))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246 (defun org-kill-is-subtree-p (&optional txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2247 "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
2248 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
2249 headline level is not the largest headline level in the tree.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2250 So this will actually accept several entries of equal levels as well,
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 which is OK for `org-paste-subtree'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 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
2253 (let* ((kill (or txt (current-kill 0) ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 (start-level (and (string-match (concat "\\`" outline-regexp) kill)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (re (concat "^" outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 (start 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 (if (not start-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 nil ;; does not even start with a heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (while (setq start (string-match re kill (1+ start)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (if (< (- (match-end 0) (match-beginning 0)) start-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 (throw 'exit nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 ;;; Completion
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 (defun org-complete (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 "Perform completion on word at point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270 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
2271 `org-todo-keywords'.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2272 If the current word is preceded by a backslash, completes the TeX symbols
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 that are supported for HTML support.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2274 If the current word is preceded by \"#+\", completes special words for
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 setting file options.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 At all other locations, this simply calls `ispell-complete-word'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (let* ((end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 (beg (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281 (if (equal (char-before (point)) ?\ ) (backward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282 (skip-chars-backward "a-zA-Z0-9_:")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 (texp (equal (char-before beg) ?\\))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 "#+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 (pattern (buffer-substring-no-properties beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 (completion-ignore-case opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 (type nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 (table (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 (opt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 (setq type :opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 (mapcar (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 (cons (match-string 2 x) (match-string 1 x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 (org-split-string (org-get-current-options) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 (texp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 (setq type :tex)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300 org-html-entities)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 ((string-match "\\`\\*+[ \t]*\\'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302 (buffer-substring (point-at-bol) beg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 (setq type :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 (mapcar 'list org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 (t (progn (ispell-complete-word arg) (throw 'exit nil)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306 (completion (try-completion pattern table)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 (cond ((eq completion t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (if (equal type :opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 (insert (substring (cdr (assoc (upcase pattern) table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 (length pattern)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 ((null completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 (message "Can't find completion for \"%s\"" pattern)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2313 (ding))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2314 ((not (string= pattern completion))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2315 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 (if (string-match " +$" completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 (setq completion (replace-match "" t t completion)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 (insert completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 (if (get-buffer-window "*Completions*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320 (delete-window (get-buffer-window "*Completions*")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321 (if (and (eq type :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322 (assoc completion table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 (insert " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 (if (and (equal type :opt) (assoc completion table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326 "Press \\[org-complete] again to insert example settings"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2327 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2328 (message "Making completion list...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 (let ((list (sort (all-completions pattern table) 'string<)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 (with-output-to-temp-buffer "*Completions*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (display-completion-list list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 (message "Making completion list...%s" "done"))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 ;;; Comments, TODO and DEADLINE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336 (defun org-toggle-comment ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 "Change the COMMENT state of an entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2341 (if (looking-at (concat outline-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 "\\( +\\<" org-comment-string "\\>\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (replace-match "" t t nil 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 (if (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 (goto-char (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347 (insert " " org-comment-string))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2349 (defvar org-last-todo-state-is-todo nil
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2350 "This is non-nil when the last TODO state change led to a TODO state.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2351 If the last change removed the TODO tag or switched to DONE, then
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2352 this is nil.")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2353
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 (defun org-todo (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 "Change the TODO state of an item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 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
2357 like
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358 *** TODO Write paper
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 *** DONE Call mom
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 The different keywords are specified in the variable `org-todo-keywords'. By
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 default the available states are \"TODO\" and \"DONE\".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 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
2364 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
2365 DONE are present, add TODO at the beginning of the heading.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 With prefix arg, use completion to determined the new state. With numeric
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 prefix arg, switch to that state."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 (if (looking-at outline-regexp) (goto-char (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373 (or (looking-at (concat " +" org-todo-regexp " *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374 (looking-at " *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 (let* ((this (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 (completion-ignore-case t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377 (member (member this org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 (tail (cdr member))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 (state (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 ((equal arg '(4))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2381 ;; Read a state with completion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2382 (completing-read "State: " (mapcar (lambda(x) (list x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 org-todo-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385 (arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2386 ;; user requests a specific state
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2387 (nth (1- (prefix-numeric-value arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388 org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2389 ((null member) (car org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2390 ((null tail) nil) ;; -> first entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2391 ((eq org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2392 (car tail))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2393 ((memq org-todo-interpretation '(type priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2394 (if (eq this-command last-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 (car tail)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396 (if (> (length tail) 0) org-done-string nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2397 (t nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2398 (next (if state (concat " " state " ") " ")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2399 (replace-match next t t)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2400 (setq org-last-todo-state-is-todo
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2401 (not (equal state org-done-string)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 (run-hooks 'org-after-todo-state-change-hook)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 ;; Fixup cursor location if close to the keyword
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2404 (if (and (outline-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405 (not (bolp))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2406 (save-excursion (beginning-of-line 1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 (looking-at org-todo-line-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 (< (point) (+ 2 (or (match-end 2) (match-end 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 (goto-char (or (match-end 2) (match-end 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411 (just-one-space))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413 (defun org-show-todo-tree (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 "Make a compact tree which shows all headlines marked with TODO.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 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
2416 headlines above the match."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418 (let ((case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 (kwd-re (if arg org-todo-regexp org-not-done-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2420 (message "%d TODO entries found"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2421 (org-occur (concat "^" outline-regexp " +" kwd-re )))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2422
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423 (defun org-deadline ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 "Insert the DEADLINE: string to make a deadline.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425 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
2426 to modify it to the correct date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429 org-deadline-string " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430 (format-time-string (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 (org-read-date nil 'to-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 "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
2434
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 (defun org-schedule ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 "Insert the SCHEDULED: string to schedule a TODO item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437 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
2438 to modify it to the correct date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2439 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2440 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 org-scheduled-string " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 (format-time-string (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 (org-read-date nil 'to-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 "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
2446
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2447
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2448 (defun org-occur (regexp &optional callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 "Make a compact tree which shows all matches of REGEXP.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 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
2451 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
2452 to make sure editing the matching entry is easy.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 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
2454 that the match should indeed be shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2455 (interactive "sRegexp: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2456 (setq regexp (org-check-occur-regexp regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 (let ((cnt 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 (hide-sublevels 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 (when (or (not callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 (funcall callback))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 (setq cnt (1+ cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 (org-show-hierarchy-above))))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2466 (run-hooks 'org-occur-hook)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 (if (interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 (message "%d match(es) for regexp %s" cnt regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469 cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2470
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 (defun org-show-hierarchy-above ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 "Make sure point and the headings hierarchy above is visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 (if (org-on-heading-p t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 (org-flag-heading nil) ; only show the heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 (org-show-hidden-entry)) ; show entire entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 (save-excursion
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2477 (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
2478 (outline-next-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 (save-excursion ; show all higher headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 (while (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 (progn (org-up-heading-all 1) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 (error nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 (org-flag-heading nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 ;;; Priorities
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z]\\)\\] ?\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 "Regular expression matching the priority indicator.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2491 (defvar org-remove-priority-next-time nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2492
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 (defun org-priority-up ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 "Increase the priority of the current item."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 (org-priority 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 (defun org-priority-down ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 "Decrease the priority of the current item."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (org-priority 'down))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2503 (defun org-priority (&optional action)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 "Change the priority of an item by ARG.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 ACTION can be set, up, or down."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (setq action (or action 'set))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 (let (current new news have remove)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (if (looking-at org-priority-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (setq current (string-to-char (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 have t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 (setq current org-default-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516 ((eq action 'set)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 (message (format "Priority A-%c, SPC to remove: " org-lowest-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 (setq new (read-char-exclusive))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2519 (cond ((equal new ?\ ) (setq remove t))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2520 ((or (< (upcase new) ?A) (> (upcase new) org-lowest-priority))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2521 (error "Priority must be between `%c' and `%c'"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2522 ?A org-lowest-priority))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523 ((eq action 'up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 (setq new (1- current)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 ((eq action 'down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 (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
2527 (t (error "Invalid action")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 (setq new (min (max ?A (upcase new)) org-lowest-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2529 (setq news (format "%c" new))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 (if have
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 (if remove
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 (replace-match "" t t nil 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 (replace-match news t t nil 2))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2534 (if remove
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2535 (error "No priority cookie found in line")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2536 (looking-at org-todo-line-regexp)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2537 (if (match-end 2)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2538 (progn
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2539 (goto-char (match-end 2))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2540 (insert " [#" news "]"))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2541 (goto-char (match-beginning 3))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2542 (insert "[#" news "] ")))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 (if remove
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 (message "Priority removed")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 (message "Priority of current item set to %s" news))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 (defun org-get-priority (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 "Find priority cookie and return priority."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (if (not (string-match org-priority-regexp s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (* 1000 (- org-lowest-priority org-default-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 (* 1000 (- org-lowest-priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 (string-to-char (match-string 2 s)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2555
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2556 ;;; Timestamps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 (defvar org-last-changed-timestamp nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2560 (defun org-time-stamp (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 "Prompt for a date/time and insert a time stamp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 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
2563 with a prefix argument, the time stamp will contain date and time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 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
2565 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
2566 So if you press just return without typing anything, the time stamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 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
2568 at the cursor, it will be modified."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (let ((fmt (if arg (cdr org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2571 (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2572 (org-time-was-given nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573 time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 ((and (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576 (eq last-command 'org-time-stamp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2577 (eq this-command 'org-time-stamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 (insert "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 (insert (format-time-string fmt time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 ((org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (and (org-at-timestamp-p) (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (setq org-last-changed-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 (format-time-string fmt time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2590 (message "Timestamp updated"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 (insert (format-time-string fmt time))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597 ;;; FIXME: Make the function take "Fri" as "next friday"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 (defun org-read-date (&optional with-time to-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599 "Read a date and make things smooth for the user.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600 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
2601 which will at least partially be understood by `parse-time-string'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2602 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
2603 hour and minute. For example,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 3-2-5 --> 2003-02-05
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 feb 15 --> currentyear-02-15
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 sep 12 9 --> 2009-09-12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 12:45 --> today 12:45
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 22 sept 0:34 --> currentyear-09-22 0:34
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 12 --> currentyear-currentmonth-12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 The function understands only English month and weekday abbreviations,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 but this can be configured with the variables `parse-time-months' and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 `parse-time-weekdays'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 While prompting, a calendar is popped up - you can also select the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 date with the mouse (button 1). The calendar shows a period of three
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
2617 month. To scroll it to other months, use the keys `>' and `<'.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 If you don't like the calendar, turn it off with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 \(setq org-popup-calendar-for-date-prompt nil).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621 With optional argument TO-TIME, the date will immediately be converted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 to an internal time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 With an optional argument WITH-TIME, the prompt will suggest to also
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 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
2625 enter a time, and this function will inform the calling routine about
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2626 this change. The calling routine may then choose to change the format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 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
2628 (let* ((default-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 ;; Default time is either today, or, when entering a range,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 ;; the range start.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2631 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (concat org-ts-regexp "--\\=")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 (- (point) 20) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2635 (apply
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 (mapcar (lambda(x) (or x 0)) ;; FIXME: Problem with timezone?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (parse-time-string (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 (timestr (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 (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
2642 (prompt (format "YYYY-MM-DD [%s]: " timestr))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 ans ans1 ans2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 second minute hour day month year tl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 (if org-popup-calendar-for-date-prompt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 ;; Also show a calendar for date selection
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648 ;; Copied (with modifications) from planner.el by John Wiegley
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652 (calendar-forward-day (- (time-to-days default-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (calendar-absolute-from-gregorian
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 (calendar-current-date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2655 (let* ((old-map (current-local-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656 (map (copy-keymap calendar-mode-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (minibuffer-local-map (copy-keymap minibuffer-local-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 (define-key map (kbd "RET") 'org-calendar-select)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 (define-key map (if org-xemacs-p [button1] [mouse-1])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 'org-calendar-select)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 (define-key minibuffer-local-map [(meta shift left)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (org-eval-in-calendar '(calendar-backward-month 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2664 (define-key minibuffer-local-map [(meta shift right)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2665 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2666 (org-eval-in-calendar '(calendar-forward-month 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2667 (define-key minibuffer-local-map [(shift up)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2668 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669 (org-eval-in-calendar '(calendar-backward-week 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 (define-key minibuffer-local-map [(shift down)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2672 (org-eval-in-calendar '(calendar-forward-week 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2673 (define-key minibuffer-local-map [(shift left)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 (org-eval-in-calendar '(calendar-backward-day 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2676 (define-key minibuffer-local-map [(shift right)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 (org-eval-in-calendar '(calendar-forward-day 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 (define-key minibuffer-local-map ">"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681 (org-eval-in-calendar '(scroll-calendar-left 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2682 (define-key minibuffer-local-map "<"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2683 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2684 (org-eval-in-calendar '(scroll-calendar-right 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2685 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2686 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2687 (use-local-map map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2688 (setq ans (read-string prompt "" nil nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2689 (setq ans (or ans1 ans2 ans)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2690 (use-local-map old-map)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2691 ;; Naked prompt only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 (setq ans (read-string prompt "" nil timestr)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2694 (if (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695 "^ *\\(\\([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
2696 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 (setq year (if (match-end 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 (string-to-number (match-string 2 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699 (string-to-number (format-time-string "%Y")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700 month (string-to-number (match-string 3 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701 day (string-to-number (match-string 4 ans)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 (if (< year 100) (setq year (+ 2000 year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2703 (setq ans (replace-match (format "%04d-%02d-%02d" year month day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 t t ans))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 (setq tl (parse-time-string ans)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 year (or (nth 5 tl) (string-to-number (format-time-string "%Y")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2707 month (or (nth 4 tl) (string-to-number (format-time-string "%m")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2708 day (or (nth 3 tl) (string-to-number (format-time-string "%d")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2709 hour (or (nth 2 tl) (string-to-number (format-time-string "%H")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2710 minute (or (nth 1 tl) (string-to-number (format-time-string "%M")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 second (or (nth 0 tl) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2712 (if (and (boundp 'org-time-was-given)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2713 (nth 2 tl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2714 (setq org-time-was-given t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2715 (if (< year 100) (setq year (+ 2000 year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2716 (if to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2717 (encode-time second minute hour day month year)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2718 (if (or (nth 1 tl) (nth 2 tl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2719 (format "%04d-%02d-%02d %02d:%02d" year month day hour minute)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2720 (format "%04d-%02d-%02d" year month day)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2721
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722 (defun org-eval-in-calendar (form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 "Eval FORM in the calendar window and return to current window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2724 Also, store the cursor date in variable ans2."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2725 (let ((sw (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2726 (select-window (get-buffer-window "*Calendar*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2727 (eval form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2728 (when (calendar-cursor-to-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2729 (let* ((date (calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2730 (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
2731 (setq ans2 (format-time-string "%Y-%m-%d" time))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2732 (select-window sw)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2733
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2734 (defun org-calendar-select ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 "Return to `org-read-date' with the date currently selected.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 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
2737 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2738 (when (calendar-cursor-to-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2739 (let* ((date (calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2740 (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
2741 (setq ans1 (format-time-string "%Y-%m-%d" time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2742 (if (active-minibuffer-window) (exit-minibuffer))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2743
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2744 (defun org-check-deadlines (ndays)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2745 "Check if there are any deadlines due or past due.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2746 A deadline is considered due if it happens within `org-deadline-warning-days'
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2747 days from today's date. If the deadline appears in an entry marked DONE,
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2748 it is not shown. The prefix arg NDAYS can be used to test that many
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2749 days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are shown."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2750 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2751 (let* ((org-warn-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2752 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753 ((equal ndays '(4)) 100000)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754 (ndays (prefix-numeric-value ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2755 (t org-deadline-warning-days)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 (case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2757 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 (callback
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2759 (lambda ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 (and (let ((d1 (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2761 (d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2762 (org-time-string-to-time (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2763 (< (- d2 d1) org-warn-days))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2764 (not (org-entry-is-done-p))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2765 (message "%d deadlines past-due or due within %d days"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 (org-occur regexp callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767 org-warn-days)))
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-evaluate-time-range (&optional to-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770 "Evaluate a time range by computing the difference between start and end.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 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
2772 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
2773 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
2774 next column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775 For time difference computation, a year is assumed to be exactly 365
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2776 days in order to avoid rounding problems."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2777 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779 (unless (org-at-date-range-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 (goto-char (point-at-bol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 (re-search-forward org-tr-regexp (point-at-eol) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 (if (not (org-at-date-range-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783 (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
2784 (let* ((ts1 (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 (ts2 (match-string 2))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2786 (havetime (or (> (length ts1) 15) (> (length ts2) 15)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2787 (match-end (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 (time1 (org-time-string-to-time ts1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (time2 (org-time-string-to-time ts2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790 (t1 (time-to-seconds time1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791 (t2 (time-to-seconds time2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 (diff (abs (- t2 t1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 (negative (< (- t2 t1) 0))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2794 ;; (ys (floor (* 365 24 60 60)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2795 (ds (* 24 60 60))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2796 (hs (* 60 60))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797 (fy "%dy %dd %02d:%02d")
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2798 (fy1 "%dy %dd")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2799 (fd "%dd %02d:%02d")
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2800 (fd1 "%dd")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2801 (fh "%02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 y d h m align)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2803 ;; FIXME: Should I re-introduce years, make year refer to same date?
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2804 ;; This would be the only useful way to have years, actually.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2805 (if havetime
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2806 (setq ; y (floor (/ diff ys)) diff (mod diff ys)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2807 y 0
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2808 d (floor (/ diff ds)) diff (mod diff ds)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2809 h (floor (/ diff hs)) diff (mod diff hs)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2810 m (floor (/ diff 60)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2811 (setq ; y (floor (/ diff ys)) diff (mod diff ys)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2812 y 0
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2813 d (floor (+ (/ diff ds) 0.5))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2814 h 0 m 0))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2815 (if (not to-buffer)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2816 (message (org-make-tdiff-string y d h m))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2817 (when (org-at-table-p)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2818 (goto-char match-end)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2819 (setq align t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2820 (and (looking-at " *|") (goto-char (match-end 0))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2821 (if (looking-at
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2822 "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2823 (replace-match ""))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2824 (if negative (insert " -"))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2825 (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2826 (if (> d 0) (insert " " (format (if havetime fd fd1) d h m))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2827 (insert " " (format fh h m))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2828 (if align (org-table-align))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2829 (message "Time difference inserted"))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2830
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831 (defun org-make-tdiff-string (y d h m)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2832 (let ((fmt "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2833 (l nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2834 (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
2835 l (push y l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836 (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
2837 l (push d l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 (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
2839 l (push h l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840 (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
2841 l (push m l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 (apply 'format fmt (nreverse l))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 (defun org-time-string-to-time (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (apply 'encode-time (org-parse-time-string s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (defun org-parse-time-string (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 "Parse the standard Org-mode time string.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
2849 This should be a lot faster than the normal `parse-time-string'."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2850 (if (string-match org-ts-regexp1 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2851 (list 0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852 (string-to-number (or (match-string 8 s) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853 (string-to-number (or (match-string 7 s) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2854 (string-to-number (match-string 4 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 (string-to-number (match-string 3 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 (string-to-number (match-string 2 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 nil nil nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 (make-list 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860 (defun org-timestamp-up (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 "Increase the date item at the cursor by one.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 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
2863 the day, change that.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 With prefix ARG, change by that many units."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 (org-timestamp-change (prefix-numeric-value arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 (defun org-timestamp-down (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 "Decrease the date item at the cursor by one.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 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
2871 the day, change that.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872 With prefix ARG, change by that many units."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 (org-timestamp-change (- (prefix-numeric-value arg))))
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-timestamp-up-day (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2877 "Increase the date in the time stamp by one day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2878 With prefix ARG, change that many days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 (org-timestamp-change (prefix-numeric-value arg) 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 (defun org-timestamp-down-day (&optional arg)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2883 "Decrease the date in the time stamp by one day.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 With prefix ARG, change that many days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 (org-timestamp-change (- (prefix-numeric-value arg)) 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 (defsubst org-pos-in-match-range (pos n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 (and (match-beginning n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 (<= (match-beginning n) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 (>= (match-end n) pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 (defun org-at-timestamp-p ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2894 "Determine if the cursor is or at a timestamp."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2895 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 (let* ((tsr org-ts-regexp2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 (ans (or (looking-at tsr)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2899 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900 (skip-chars-backward "^<\n\r\t")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2901 (if (> (point) 1) (backward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (and (looking-at tsr)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 (> (- (match-end 0) pos) -1))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 (and (boundp 'org-ts-what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 (setq org-ts-what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907 ((org-pos-in-match-range pos 2) 'year)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908 ((org-pos-in-match-range pos 3) 'month)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909 ((org-pos-in-match-range pos 7) 'hour)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 ((org-pos-in-match-range pos 8) 'minute)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2911 ((or (org-pos-in-match-range pos 4)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912 (org-pos-in-match-range pos 5)) 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913 (t 'day))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916 (defun org-timestamp-change (n &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 "Change the date in the time stamp at point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2918 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
2919 `year', `minute', `second'. If WHAT is not given, the cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 in the timestamp determines what will be changed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 (let ((fmt (car org-time-stamp-formats))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2922 org-ts-what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924 ts time time0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926 (error "Not at a timestamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927 (setq org-ts-what (or what org-ts-what))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928 (setq fmt (if (<= (abs (- (cdr org-ts-lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 (cdr org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933 (setq ts (match-string 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 (replace-match "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 (setq time0 (org-parse-time-string ts))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 (setq time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 (apply 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2938 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2939 (list (or (car time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2940 (list (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2941 (list (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942 (list (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2943 (list (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 (list (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 (nthcdr 6 time0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 (if (eq what 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947 (let ((cal-date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 (set-buffer "*Calendar*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 (calendar-cursor-to-date)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 (setcar time0 (or (car time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 (setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957 (setcar (nthcdr 2 time0) (or (nth 1 time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 (setq time (apply 'encode-time time0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 (insert (setq org-last-changed-timestamp (format-time-string fmt time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 ;; Try to recenter the calendar window, if any
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 (if (and org-calendar-follow-timestamp-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 (get-buffer-window "*Calendar*" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964 (memq org-ts-what '(day month year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2965 (org-recenter-calendar (time-to-days time)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2967 (defun org-recenter-calendar (date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2968 "If the calendar is visible, recenter it to DATE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (let* ((win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970 (cwin (get-buffer-window "*Calendar*" t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 (when cwin
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 (select-window cwin)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (calendar-goto-date (if (listp date) date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974 (calendar-gregorian-from-absolute date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2975 (select-window win))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 (defun org-goto-calendar (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 "Go to the Emacs calendar at the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979 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
2980 A prefix ARG can be used force the current date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 (let ((tsr org-ts-regexp) diff)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2983 (if (or (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2986 (looking-at (concat ".*" tsr))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2987 (let ((d1 (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2988 (d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2989 (org-time-string-to-time (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2990 (setq diff (- d2 d1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2991 (calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 (calendar-goto-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2993 (if (and diff (not arg)) (calendar-forward-day diff))))
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 (defun org-date-from-calendar ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2996 "Insert time stamp corresponding to cursor date in *Calendar* buffer.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997 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
2998 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999 (org-timestamp-change 0 'calendar))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3000
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3001 ;;; Agenda, and Diary Integration
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3002
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3003 ;;; Define the mode
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 (defvar org-agenda-mode-map (make-sparse-keymap)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3006 "Keymap for `org-agenda-mode'.")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3007
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3008 (defvar org-agenda-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3009 (defvar org-agenda-follow-mode nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3010 (defvar org-agenda-buffer-name "*Org Agenda*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3011 (defvar org-agenda-redo-command nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3012
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3013 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 (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
3015 "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
3016
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
3017 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
3018
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
3019 \\{org-agenda-mode-map}"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 (kill-all-local-variables)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 (setq major-mode 'org-agenda-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3023 (setq mode-name "Org-Agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3024 (use-local-map org-agenda-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 (easy-menu-add org-agenda-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 (if org-startup-truncated (setq truncate-lines t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3028 (add-hook 'pre-command-hook 'org-unhighlight nil 'local)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3029 (setq org-agenda-follow-mode nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3030 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3031 '("Agenda") "Agenda Files"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3032 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3033 (list
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3034 ["Edit File List" (customize-variable 'org-agenda-files) t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3035 "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3036 (mapcar 'org-file-menu-entry org-agenda-files)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3037 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3038 (run-hooks 'org-agenda-mode-hook))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3039
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3040 (define-key org-agenda-mode-map [(tab)] 'org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3041 (define-key org-agenda-mode-map [(return)] 'org-agenda-switch-to)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3042 (define-key org-agenda-mode-map " " 'org-agenda-show)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3043 (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
3044 (define-key org-agenda-mode-map "o" 'delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3045 (define-key org-agenda-mode-map "l" 'org-agenda-recenter)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3046 (define-key org-agenda-mode-map "t" 'org-agenda-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3047 (define-key org-agenda-mode-map "." 'org-agenda-goto-today)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3048 (define-key org-agenda-mode-map "w" 'org-agenda-toggle-week-view)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3049 (define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3050 (define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3051
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3052 (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3053 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3054 (while l (define-key org-agenda-mode-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3055 (int-to-string (pop l)) 'digit-argument)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 (define-key org-agenda-mode-map "f" 'org-agenda-follow-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 (define-key org-agenda-mode-map "d" 'org-agenda-toggle-diary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (define-key org-agenda-mode-map "r" 'org-agenda-redo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 (define-key org-agenda-mode-map "q" 'org-agenda-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 (define-key org-agenda-mode-map "x" 'org-agenda-exit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 (define-key org-agenda-mode-map "P" 'org-agenda-show-priority)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3063 (define-key org-agenda-mode-map "n" 'next-line)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3064 (define-key org-agenda-mode-map "p" 'previous-line)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3065 (define-key org-agenda-mode-map "\C-n" 'org-agenda-next-date-line)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3066 (define-key org-agenda-mode-map "\C-p" 'org-agenda-previous-date-line)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3067 (define-key org-agenda-mode-map "," 'org-agenda-priority)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3068 (define-key org-agenda-mode-map "\C-c," 'org-agenda-priority)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 (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
3070 (define-key org-agenda-mode-map "c" 'org-agenda-goto-calendar)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3071 (eval-after-load "calendar"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3072 '(define-key calendar-mode-map org-calendar-to-agenda-key
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3073 'org-calendar-goto-agenda))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3074 (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
3075 (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
3076 (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
3077 (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
3078 (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
3079 (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
3080 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3081 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3083 (define-key org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3084 (define-key org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3085 (define-key org-agenda-mode-map [(right)] 'org-agenda-later)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3087
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3088 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3089 "Local keymap for agenda entries from Org-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3090
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 (define-key org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3092 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 (define-key org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 '("Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098 ("Agenda Files")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100 ["Show" org-agenda-show t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 ["Go To (other window)" org-agenda-goto t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3102 ["Go To (one window)" org-agenda-switch-to t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103 ["Follow Mode" org-agenda-follow-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 :style toggle :selected org-agenda-follow-mode :active t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3105 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3106 ["Cycle TODO" org-agenda-todo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 ("Reschedule"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 ["Reschedule +1 day" org-agenda-date-later t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 ["Reschedule -1 day" org-agenda-date-earlier t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3110 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3111 ["Reschedule to ..." org-agenda-date-prompt t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112 ("Priority"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3113 ["Set Priority" org-agenda-priority t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 ["Increase Priority" org-agenda-priority-up t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3115 ["Decrease Priority" org-agenda-priority-down t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3116 ["Show Priority" org-agenda-show-priority t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3118 ["Rebuild" org-agenda-redo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3119 ["Goto Today" org-agenda-goto-today t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 ["Next Dates" org-agenda-later (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3121 ["Previous Dates" org-agenda-earlier (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3122 "--"
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3123 ["Week/Day View" org-agenda-toggle-week-view
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3124 (local-variable-p 'starting-day)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125 ["Include Diary" org-agenda-toggle-diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126 :style toggle :selected org-agenda-include-diary :active t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3127 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 ["New Diary Entry" org-agenda-diary-entry t]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3129 ("Calendar Commands"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3130 ["Goto Calendar" org-agenda-goto-calendar t]
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3131 ["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
3132 ["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
3133 ["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
3134 ["Convert" org-agenda-convert-date t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136 ["Quit" org-agenda-quit t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 ["Exit and Release Buffers" org-agenda-exit t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3138 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3139
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3140 (defvar org-agenda-markers nil
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3141 "List of all currently active markers created by `org-agenda'.")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3142 (defvar org-agenda-last-marker-time (time-to-seconds (current-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 "Creation time of the last agenda marker.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3145 (defun org-agenda-new-marker (&optional pos)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146 "Return a new agenda marker.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 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
3148 no longer in use."
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3149 (let ((m (copy-marker (or pos (point)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150 (setq org-agenda-last-marker-time (time-to-seconds (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 (push m org-agenda-markers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3152 m))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3153
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3154 (defun org-agenda-maybe-reset-markers (&optional force)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3155 "Reset markers created by `org-agenda'. But only if they are old enough."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3156 (if (or force
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3157 (> (- (time-to-seconds (current-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3158 org-agenda-last-marker-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3159 5))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3160 (while org-agenda-markers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3161 (move-marker (pop org-agenda-markers) nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3162
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3163 (defvar org-agenda-new-buffers nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3164 "Buffers created to visit agenda files.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3165
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3166 (defun org-get-agenda-file-buffer (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 "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
3168 it to the list of buffers which might be released later."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 (let ((buf (find-buffer-visiting file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170 (if buf
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 buf ; just return it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172 ;; Make a new buffer and remember it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 (setq buf (find-file-noselect file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174 (if buf (push buf org-agenda-new-buffers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3175 buf)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3176
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3177 (defun org-release-buffers (blist)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 "Release all buffers in list, asking the user for confirmation when needed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179 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
3180 \(if the user agrees) and then killed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3181 (let (buf file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 (while (setq buf (pop blist))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 (setq file (buffer-file-name buf))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3184 (when (and (buffer-modified-p buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3185 file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3186 (y-or-n-p (format "Save file %s? " file)))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3187 (with-current-buffer buf (save-buffer)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3188 (kill-buffer buf))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3190 (defvar org-respect-restriction nil) ; Dynamically-scoped param.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3191
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3192 (defun org-timeline (&optional include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 "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
3194 Only entries with a time stamp of today or later will be listed. With
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3195 one \\[universal-argument] prefix argument, past entries will also be listed.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3196 With two \\[universal-argument] prefixes, all unfinished TODO items will also be shown,
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 under the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 If the buffer contains an active region, only check the region for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 dates."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 (org-agenda-maybe-reset-markers 'force)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3203 (org-compile-prefix-format org-timeline-prefix-format)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 (let* ((dopast include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (dotodo (equal include-all '(16)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 (entry (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207 (org-agenda-files (list (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (date (calendar-current-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3209 (win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3210 (pos1 (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211 (beg (if (org-region-active-p) (region-beginning) (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 (end (if (org-region-active-p) (region-end) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3213 (day-numbers (org-get-all-dates beg end 'no-ranges
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 t)) ; always include today
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215 (today (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3216 (org-respect-restriction t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217 (past t)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3218 s e rtn d)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 (setq org-agenda-redo-command
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3220 (list 'progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 (list 'switch-to-buffer-other-window (current-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222 (list 'org-timeline include-all)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223 (if (not dopast)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 ;; Remove past dates from the list of dates.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 (setq day-numbers (delq nil (mapcar (lambda(x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226 (if (>= x today) x nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227 day-numbers))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3228 (switch-to-buffer-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3229 (get-buffer-create org-agenda-buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3230 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3231 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3232 (org-agenda-mode) (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (while (setq d (pop day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 (if (and (>= d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 dopast
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 past)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 (setq past nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (insert (make-string 79 ?-) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (setq date (calendar-gregorian-from-absolute d))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241 (setq s (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242 (if dotodo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 (setq rtn (org-agenda-get-day-entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 entry date :todo :timestamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 (setq rtn (org-agenda-get-day-entries entry date :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246 (if (or rtn (equal d today))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 (insert (calendar-day-name date) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 (number-to-string (extract-calendar-day date)) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (calendar-month-name (extract-calendar-month date)) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251 (number-to-string (extract-calendar-year date)) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3252 (put-text-property s (1- (point)) 'face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3253 'org-link-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3254 (if (equal d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 (put-text-property s (1- (point)) 'org-today t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 (insert (org-finalize-agenda-entries rtn) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 (put-text-property s (1- (point)) 'day d))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259 (setq buffer-read-only t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260 (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
3261 (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3262 (when (not org-select-timeline-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3263 (select-window win)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3264 (goto-char pos1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3265
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3267 (defun org-agenda (&optional include-all start-day ndays)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3268 "Produce a weekly view from all files in variable `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 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
3270 will be able to go to other weeks.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3271 With one \\[universal-argument] prefix argument INCLUDE-ALL, all unfinished TODO items will
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3272 also be shown, under the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 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
3274 given in `org-agenda-start-on-weekday'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3275 NDAYS defaults to `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 (org-agenda-maybe-reset-markers 'force)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3278 (org-compile-prefix-format org-agenda-prefix-format)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280 (let* ((org-agenda-start-on-weekday
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3281 (if (or (equal ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 (and (null ndays) (equal 1 org-agenda-ndays)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283 nil org-agenda-start-on-weekday))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3284 (files (copy-sequence org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3285 (win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3286 (today (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3287 (sd (or start-day today))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3288 (start (if (or (null org-agenda-start-on-weekday)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3289 (< org-agenda-ndays 7))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3290 sd
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3291 (let* ((nt (calendar-day-of-week
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3292 (calendar-gregorian-from-absolute sd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3293 (n1 org-agenda-start-on-weekday)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3294 (d (- nt n1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3295 (- sd (+ (if (< d 0) 7 0) d)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3296 (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
3297 s e rtn rtnall file date d start-pos end-pos)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3298 (setq org-agenda-redo-command
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3299 (list 'org-agenda include-all start-day ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3300 ;; Make the list of days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3301 (setq ndays (or ndays org-agenda-ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302 (while (> ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (push (1+ (car day-numbers)) day-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 (setq ndays (1- ndays)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 (setq day-numbers (nreverse day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 (if (not (equal (current-buffer) (get-buffer org-agenda-buffer-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3308 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309 (switch-to-buffer-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 (get-buffer-create org-agenda-buffer-name))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313 (org-agenda-mode) (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314 (set (make-local-variable 'starting-day) (car day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 (set (make-local-variable 'include-all-loc) include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3316 (when (and (or include-all org-agenda-include-all-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3317 (member today day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318 (setq files org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3319 rtnall nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3320 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3321 (catch 'nextfile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3322 (org-check-agenda-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3323 (setq date (calendar-gregorian-from-absolute today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3324 rtn (org-agenda-get-day-entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3325 file date :todo))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3327 (if rtnall (insert (org-finalize-agenda-entries rtnall) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328 (while (setq d (pop day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329 (setq date (calendar-gregorian-from-absolute d)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3330 s (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 (if (or (= d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 (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
3333 (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
3334 (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
3335 (setq end-pos (point))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336 (setq files org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3337 rtnall nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3338 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (catch 'nextfile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3340 (org-check-agenda-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341 (setq rtn (org-agenda-get-day-entries file date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343 (if org-agenda-include-diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345 (require 'diary-lib)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3346 (setq rtn (org-get-entries-from-diary date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3347 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348 (if (or rtnall org-agenda-show-all-dates)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350 (insert (format "%-9s %2d %-9s %4d\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (calendar-day-name date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3352 (extract-calendar-day date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 (calendar-month-name (extract-calendar-month date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 (extract-calendar-year date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355 (put-text-property s (1- (point)) 'face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 'org-link-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 (if rtnall (insert (org-finalize-agenda-entries rtnall) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3358 (put-text-property s (1- (point)) 'day d))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 (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
3361 (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
3362 (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
3363 (/ (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
3364 (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
3365 (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
3366 (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
3367 (recenter -1)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3368 (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
3369 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3370 (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
3371 (recenter 1))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (goto-char (or start-pos 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (if (not org-select-agenda-window) (select-window win))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374 (message "")))
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-check-agenda-file (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3377 "Make sure FILE exists. If not, ask user what to do."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3378 ;; 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
3379 ;; Could probably be fixed by explicitly going to the buffer.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380 (when (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3381 (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
3382 file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3383 (let ((r (downcase (read-char-exclusive))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3384 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3385 ((equal r ?r)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386 (org-remove-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3387 (throw 'nextfile t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388 (t (error "Abort"))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3389
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3390 (defun org-agenda-quit ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391 "Exit agenda by removing the window or the buffer."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3392 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393 (let ((buf (current-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3394 (if (not (one-window-p)) (delete-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3395 (kill-buffer buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3396 (org-agenda-maybe-reset-markers 'force)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3397
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3398 (defun org-agenda-exit ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 "Exit agenda by removing the window or the buffer.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3400 Also kill all Org-mode buffers which have been loaded by `org-agenda'.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3401 Org-mode buffers visited directly by the user will not be touched."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3402 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (org-release-buffers org-agenda-new-buffers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3404 (setq org-agenda-new-buffers nil)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3405 (org-agenda-quit))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3406
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3407 (defun org-agenda-redo ()
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3408 "Rebuild Agenda."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3409 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3410 (eval org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3411
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3412 (defun org-agenda-goto-today ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 "Go to today."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3414 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3415 (if (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3416 (let ((cmd (car org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3417 (iall (nth 1 org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3418 (nday (nth 3 org-agenda-redo-command)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3419 (eval (list cmd iall nil nday)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3420 (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
3421 (point-min)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3422
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3423 (defun org-agenda-later (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3424 "Go forward in time by `org-agenda-ndays' days.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 With prefix ARG, go forward that many times `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3426 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3427 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3428 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 (+ starting-day (* arg org-agenda-ndays))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432 (defun org-agenda-earlier (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 "Go back in time by `org-agenda-ndays' days.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 With prefix ARG, go back that many times `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3437 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3438 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 (- starting-day (* arg org-agenda-ndays))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3440
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3441 (defun org-agenda-toggle-week-view ()
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3442 "Toggle weekly/daily view for aagenda."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3443 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3444 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3445 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 (setq org-agenda-ndays
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3447 (if (equal org-agenda-ndays 1) 7 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3448 (org-agenda include-all-loc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 (or (get-text-property (point) 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3450 starting-day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3451 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3452 (message "Switched to %s view"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3453 (if (equal org-agenda-ndays 1) "day" "week")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3454
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3455 (defun org-agenda-next-date-line (&optional arg)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3456 "Jump to the next line indicating a date in agenda buffer."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3457 (interactive "p")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3458 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3459 (if (looking-at "^\\S-") (forward-char 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3460 (if (not (re-search-forward "^\\S-" nil t arg))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3461 (progn
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3462 (backward-char 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3463 (error "No next date after this line in this buffer.")))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3464 (goto-char (match-beginning 0)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3465
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3466 (defun org-agenda-previous-date-line (&optional arg)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3467 "Jump to the next line indicating a date in agenda buffer."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3468 (interactive "p")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3469 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3470 (if (not (re-search-backward "^\\S-" nil t arg))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3471 (error "No previous date before this line in this buffer.")))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3472
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3473 ;; Initialize the highlight
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3474 (defvar org-hl (funcall (if org-xemacs-p 'make-extent 'make-overlay) 1 1))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3475 (funcall (if org-xemacs-p 'set-extent-property 'overlay-put) org-hl
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3476 'face 'highlight)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3477
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3478 (defun org-highlight (begin end &optional buffer)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3479 "Highlight a region with overlay."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3480 (funcall (if org-xemacs-p 'set-extent-endpoints 'move-overlay)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3481 org-hl begin end (or buffer (current-buffer))))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3482
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3483 (defun org-unhighlight ()
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3484 "Detach overlay INDEX."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3485 (funcall (if org-xemacs-p 'detach-extent 'delete-overlay) org-hl))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3486
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3487
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3488 (defun org-agenda-follow-mode ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489 "Toggle follow mode in an agenda buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491 (setq org-agenda-follow-mode (not org-agenda-follow-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 (message "Follow mode is %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 (if org-agenda-follow-mode "on" "off")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496 (defun org-agenda-toggle-diary ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 "Toggle follow mode in an agenda buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 (setq org-agenda-include-diary (not org-agenda-include-diary))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 (org-agenda-redo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3501 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3502 (message "Diary inclusion turned %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 (if org-agenda-include-diary "on" "off")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 (defun org-agenda-set-mode-name ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3506 "Set the mode name to indicate all the small mode settings."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507 (setq mode-name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 (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
3509 (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
3510 (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
3511 (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
3512 (if org-agenda-include-diary " Diary" "")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3513 (force-mode-line-update))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3514
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3515 (defun org-agenda-post-command-hook ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3516 (and (eolp) (not (bolp)) (backward-char 1))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3517 (if (and org-agenda-follow-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518 (get-text-property (point) 'org-marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519 (org-agenda-show)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3521 (defvar org-disable-diary nil) ;Dynamically-scoped param.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3522
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523 (defun org-get-entries-from-diary (date)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3524 "Get the (Emacs Calendar) diary entries for DATE."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3525 (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
3526 (diary-display-hook '(fancy-diary-display))
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
3527 (list-diary-entries-hook
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3528 (cons 'org-diary-default-entry list-diary-entries-hook))
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
3529 entries
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3530 (org-disable-diary t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 (list-diary-entries date 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 (if (not (get-buffer fancy-diary-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535 (setq entries nil)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3536 (with-current-buffer fancy-diary-buffer
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538 (if (= (point-max) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 ;; No entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 (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
3541 ;; 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
3542 (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
3543 ;; 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
3544 (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
3545 (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
3546 (setq entries (buffer-substring (point-min) (- (point-max) 1)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (set-buffer-modified-p nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3548 (kill-buffer fancy-diary-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3549 (when entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 (setq entries (org-split-string entries "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 (setq entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552 (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553 (lambda (x)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3554 (setq x (org-format-agenda-item "" x "Diary"))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3555 ;; Extend the text properties to the beginning of the line
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3556 (add-text-properties
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3557 0 (length x)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3558 (text-properties-at (1- (length x)) x)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3559 x)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560 x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561 entries)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3563 (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
3564 "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
3565 This gets rid of the date, the underline under the date, and
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3566 the dummy entry installed by `org-mode' to ensure non-empty diary for each
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3567 date. Itt also removes lines that contain only whitespace."
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3568 (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
3569 (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
3570 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3571 (replace-match "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3572 (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
3573 (replace-match "")
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3574 (while (re-search-backward "^ +\n?" nil t) (replace-match "")))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3575 (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
3576 (delete-region (point-min) (min (point-max) (1+ (match-end 0)))))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3577 (goto-char (point-min))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3578 (while (re-search-forward "^ +\n" nil t)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3579 (replace-match ""))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3580 (goto-char (point-min))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3581 (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
3582 (replace-match "")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3583
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3584 ;; Advise the add-to-diary-list function to allow org to jump to
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3585 ;; diary entries. Wrapped into eval-after-load to avoid loading
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3586 ;; advice unnecessarily
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3587 (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
3588 '(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
3589 "Make the position visible."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3590 (if (and org-disable-diary ;; called from 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
3591 (stringp string)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3592 (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
3593 (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
3594 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
3595 (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
3596 '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
3597 'help-echo
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3598 (format
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3599 "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
3600 (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
3601 '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
3602 '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
3603 string))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3604
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3605 (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
3606 "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
3607 Needed to avoid empty dates which mess up holiday display."
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3608 ;; Catch the error if dealing with the new add-to-diary-alist
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3609 (condition-case nil
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3610 (add-to-diary-list original-date "Org-mode dummy" "")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3611 (error
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3612 (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
3613
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614 (defun org-add-file (&optional file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 "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
3616 These are the files which are being checked for agenda entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617 Optional argument FILE means, use this file instead of the current.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618 It is possible (but not recommended) to add this function to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 `org-mode-hook'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 (let* ((file (or file (buffer-file-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623 (if (interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 (error "Buffer is not visiting a file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 (throw 'exit nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 (true-file (file-truename file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 (afile (abbreviate-file-name file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628 (present (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630 (equal true-file (file-truename x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 (if (not present)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 (setq org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635 (cons afile org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 ;; Make sure custom.el does not end up with Org-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3638 (customize-save-variable 'org-agenda-files org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 (message "Added file: %s" afile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641 (message "File was already in list: %s" afile)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3643 (defun org-remove-file (&optional file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 "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
3645 These are the files which are being checked for agenda entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 Optional argument FILE means, use this file instead of the current."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648 (let* ((file (or file (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 (true-file (file-truename file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3650 (afile (abbreviate-file-name file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 (files (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 (if (equal true-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 (file-truename x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655 nil x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656 org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 (if (not (= (length files) (length org-agenda-files)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659 (setq org-agenda-files files)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 (customize-save-variable 'org-agenda-files org-agenda-files)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662 (message "Removed file: %s" afile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 (message "File was not in list: %s" afile))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3664
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3665 (defun org-file-menu-entry (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666 (vector file (list 'find-file file) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3668 (defun org-get-all-dates (beg end &optional no-ranges force-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 "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
3670 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
3671 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
3672 sure that TODAY is included in the list."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 (let (dates date day day1 day2 ts1 ts2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674 (if force-today
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675 (setq dates (list (time-to-days (current-time)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3678 (while (re-search-forward org-ts-regexp end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 (setq day (time-to-days (org-time-string-to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680 (substring (match-string 1) 0 10))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 (or (memq day dates) (push day dates)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 (unless no-ranges
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (while (re-search-forward org-tr-regexp end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3685 (setq ts1 (substring (match-string 1) 0 10)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686 ts2 (substring (match-string 2) 0 10)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3687 day1 (time-to-days (org-time-string-to-time ts1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688 day2 (time-to-days (org-time-string-to-time ts2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3689 (while (< (setq day1 (1+ day1)) day2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 (or (memq day1 dates) (push day1 dates)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3691 (sort dates '<))))
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 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3694 (defun org-diary (&rest args)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3695 "Return diary information from org-files.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3696 This function can be used in a \"sexp\" diary entry in the Emacs calendar.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3697 It accesses org files and extracts information from those files to be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 listed in the diary. The function accepts arguments specifying what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3699 items should be listed. The following arguments are allowed:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3700
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3701 :timestamp List the headlines of items containing a date stamp or
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3702 date range matching the selected date. Deadlines will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 also be listed, on the expiration day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3705 :deadline List any deadlines past due, or due within
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3706 `org-deadline-warning-days'. The listing occurs only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 in the diary for *today*, not at any other date. If
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3708 an entry is marked DONE, it is no longer listed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 :scheduled List all items which are scheduled for the given date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 The diary for *today* also contains items which were
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3712 scheduled earlier and are not yet marked DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714 :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
3715 long list - so this is not turned on by default.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3716 Like deadlines, these entries only show up in the
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 diary for *today*, not at any other date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3718
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3719 The call in the diary file should look like this:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3720
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3721 &%%(org-diary) ~/path/to/some/orgfile.org
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3722
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3723 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
3724 all files listed in `org-agenda-files' will be checked automatically:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3725
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3726 &%%(org-diary)
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 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
3729 arguments (:deadline :scheduled :timestamp) are used. So the example above may
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3730 also be written as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3731
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3732 &%%(org-diary :deadline :timestamp :scheduled)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3733
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3734 The function expects the lisp variables `entry' and `date' to be provided
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3735 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
3736 function from a program - use `org-agenda-get-day-entries' instead."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3737 (org-agenda-maybe-reset-markers)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3738 (org-compile-agenda-prefix-format org-agenda-prefix-format)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 (setq args (or args '(:deadline :scheduled :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 (list entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3742 org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3743 file rtn results)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744 ;; 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
3745 ;; the calendar. Org Agenda will list these entries itself.
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3746 (if org-disable-diary (setq files nil))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 (setq rtn (apply 'org-agenda-get-day-entries file date args))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3749 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 (concat (org-finalize-agenda-entries results) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 (defun org-agenda-get-day-entries (file date &rest args)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3753 "Does the work for `org-diary' and `org-agenda'.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 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
3755 the one returned by `calendar-current-date'. ARGS are symbols indicating
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 which kind of entries should be extracted. For details about these, see
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 the documentation of `org-diary'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 (setq args (or args '(:deadline :scheduled :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 (let* ((org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 (org-startup-folded nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 (buffer (if (file-exists-p file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 (org-get-agenda-file-buffer file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 (error "No such file %s" file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 arg results rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3765 (if (not buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766 ;; 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
3767 (format "ORG-AGENDA-ERROR: No such org-file %s" file)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3768 (with-current-buffer buffer
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3769 (unless (eq major-mode 'org-mode)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3770 (error "Agenda file %s is not in `org-mode'" file))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 (let ((case-fold-search nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773 (save-restriction
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3774 (if org-respect-restriction
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3775 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 ;; Respect a region to restrict search
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3777 (narrow-to-region (region-beginning) (region-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 ;; If we work for the calendar or many files,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3779 ;; get rid of any restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 (widen))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3781 ;; The way we repeatedly append to `results' makes it O(n^2) :-(
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3782 (while (setq arg (pop args))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3783 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3784 ((and (eq arg :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3785 (equal date (calendar-current-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3786 (setq rtn (org-agenda-get-todos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3787 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3788 ((eq arg :timestamp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3789 (setq rtn (org-agenda-get-blocks))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3790 (setq results (append results rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3791 (setq rtn (org-agenda-get-timestamps))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3792 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3793 ((eq arg :scheduled)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3794 (setq rtn (org-agenda-get-scheduled))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3795 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3796 ((and (eq arg :deadline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3797 (equal date (calendar-current-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 (setq rtn (org-agenda-get-deadlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799 (setq results (append results rtn))))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3800 results))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3802 (defun org-entry-is-done-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3803 "Is the current entry marked DONE?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3804 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3805 (and (re-search-backward "[\r\n]\\*" nil t)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3806 (looking-at org-nl-done-regexp))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3807
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3808 (defun org-at-date-range-p ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3809 "Is the cursor inside a date range?"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3810 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3812 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3813 (let ((pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3814 (skip-chars-backward "^<\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3815 (skip-chars-backward "<")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3816 (and (looking-at org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3817 (>= (match-end 0) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3818 (throw 'exit t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3819 (skip-chars-backward "^<\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3820 (skip-chars-backward "<")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3821 (and (looking-at org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822 (>= (match-end 0) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823 (throw 'exit t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3824 nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3825
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3826 (defun org-agenda-get-todos ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3827 "Return the TODO information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3828 (let* ((props (list 'face nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3829 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3831 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3832 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 (regexp (concat "[\n\r]\\*+ *\\(" org-not-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3836 "[^\n\r]*\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 marker priority
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3838 ee txt)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 (goto-char (match-beginning 1))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3842 (setq marker (org-agenda-new-marker (point-at-bol))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3843 txt (org-format-agenda-item "" (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3844 priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3845 (+ (org-get-priority txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3846 (if org-todo-kwd-priority-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3847 (- org-todo-kwd-max-priority -2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3848 (length
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3849 (member (match-string 2) org-todo-keywords)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3850 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3851 (add-text-properties
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3852 0 (length txt) (append (list 'org-marker marker 'org-hd-marker marker
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3853 'priority priority)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3854 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3855 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3856 (push txt ee)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3857 (goto-char (match-end 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3858 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3859
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3860 (defconst org-agenda-no-heading-message
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3861 "No heading for this item in buffer or region")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3862
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3863 (defun org-agenda-get-timestamps ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3864 "Return the date stamp information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3865 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3866 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3867 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3868 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3869 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3870 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3871 (regexp (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3872 (substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3873 (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3874 (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3875 (apply 'encode-time ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3876 (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3877 0 11)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3878 marker hdmarker deadlinep scheduledp donep tmp priority
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3879 ee txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3880 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3881 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3882 (if (not (save-match-data (org-at-date-range-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3883 (progn
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3884 (setq marker (org-agenda-new-marker (match-beginning 0))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3885 tmp (buffer-substring (max (point-min)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3886 (- (match-beginning 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3887 org-ds-keyword-length))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3888 (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3889 deadlinep (string-match org-deadline-regexp tmp)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3890 scheduledp (string-match org-scheduled-regexp tmp)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3891 donep (org-entry-is-done-p))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3892 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3893 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3894 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3895 (goto-char (match-end 1))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3896 (setq hdmarker (org-agenda-new-marker))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3897 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3899 (format "%s%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3900 (if deadlinep "Deadline: " "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3901 (if scheduledp "Scheduled: " ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3902 (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3903 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3904 (setq priority (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3905 (add-text-properties
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3906 0 (length txt) (append (list 'org-marker marker
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3907 'org-hd-marker hdmarker) props)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3908 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3909 (if deadlinep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3910 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3911 0 (length txt)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3912 (list 'face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3913 (if donep 'org-done-face 'org-warning-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3914 'undone-face 'org-warning-face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3915 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3916 'priority (+ 100 priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3917 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3918 (if scheduledp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3919 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3920 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3921 (list 'face 'org-scheduled-today-face
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3922 'undone-face 'org-scheduled-today-face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3923 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3924 priority (+ 99 priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3925 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3926 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3927 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3928 (list 'priority priority) txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3929 (push txt ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3930 (outline-next-heading))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3931 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3932
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3933 (defun org-agenda-get-deadlines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3934 "Return the deadline information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3935 (let* ((wdays org-deadline-warning-days)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3936 (props (list 'mouse-face 'highlight
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3937 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3938 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3940 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3941 (regexp org-deadline-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3944 d2 diff pos pos1
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
3945 ee txt head)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947 (while (re-search-forward regexp nil t)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3948 (setq pos (1- (match-beginning 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3949 d2 (time-to-days
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (org-time-string-to-time (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951 diff (- d2 d1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3952 ;; When to show a deadline in the calendar:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3953 ;; If the expiration is within wdays warning time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3954 ;; Past-due deadlines are only shown on the current date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3955 (if (and (< diff wdays) todayp (not (= diff 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3957 (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3958 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3959 (goto-char (match-end 0))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3960 (setq pos1 (match-end 1))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961 (setq head (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962 (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3963 (progn (skip-chars-forward "^\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965 (if (string-match org-looking-at-done-regexp head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 (setq txt nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 (format "In %3d d.: " diff) head))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3969 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3970 (when txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3973 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3974 (list 'org-marker (org-agenda-new-marker pos)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3975 'org-hd-marker (org-agenda-new-marker pos1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3976 'priority (+ (- 10 diff) (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3977 'face (cond ((<= diff 0) 'org-warning-face)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3978 ((<= diff 5) 'org-scheduled-previously-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3979 (t nil))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3980 'undone-face (cond
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3981 ((<= diff 0) 'org-warning-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3982 ((<= diff 5) 'org-scheduled-previously-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3983 (t nil))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3984 'done-face 'org-done-face)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3985 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3986 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3987 (push txt ee)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3988 ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3989
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3990 (defun org-agenda-get-scheduled ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3991 "Return the scheduled information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3992 (let* ((props (list 'face 'org-scheduled-previously-face
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3993 'undone-face 'org-scheduled-previously-face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3994 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3996 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3997 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3998 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3999 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4000 (regexp org-scheduled-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4001 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4002 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4003 d2 diff pos pos1
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4004 ee txt head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4005 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4006 (while (re-search-forward regexp nil t)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4007 (setq pos (1- (match-beginning 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4008 d2 (time-to-days
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4009 (org-time-string-to-time (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4010 diff (- d2 d1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4011 ;; When to show a scheduled item in the calendar:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4012 ;; If it is on or past the date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4013 (if (and (< diff 0) todayp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4014 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4015 (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4016 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017 (goto-char (match-end 0))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4018 (setq pos1 (match-end 1))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4019 (setq head (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4020 (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4021 (progn (skip-chars-forward "^\r\n") (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4022 (if (string-match org-looking-at-done-regexp head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4023 (setq txt nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4024 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4025 (format "Sched.%2dx: " (- 1 diff)) head))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4026 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4027 (when txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4028 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4029 0 (length txt)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4030 (append (list 'org-marker (org-agenda-new-marker pos)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4031 'org-hd-marker (org-agenda-new-marker pos1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4032 'priority (+ (- 5 diff) (org-get-priority txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4033 props) txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4034 (push txt ee)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4035 ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4036
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4037 (defun org-agenda-get-blocks ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4038 "Return the date-range information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4039 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4040 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4041 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4042 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4043 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4044 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4045 (regexp org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4046 (d0 (calendar-absolute-from-gregorian date))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4047 marker hdmarker ee txt d1 d2 s1 s2)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4048 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4049 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4050 (setq s1 (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4051 s2 (match-string 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4052 d1 (time-to-days (org-time-string-to-time s1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4053 d2 (time-to-days (org-time-string-to-time s2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4054 (if (and (> (- d0 d1) -1) (> (- d2 d0) -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4055 ;; Only allow days between the limits, because the normal
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4056 ;; date stamps will catch the limits.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4057 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 (setq marker (org-agenda-new-marker (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4059 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4060 (progn
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4061 (setq hdmarker (org-agenda-new-marker (match-end 1)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062 (goto-char (match-end 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4063 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4065 (format "(%d/%d): "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 (1+ (- d0 d1)) (1+ (- d2 d1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4067 (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4068 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4069 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4070 0 (length txt) (append (list 'org-marker marker
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4071 'org-hd-marker hdmarker
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4072 'priority (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4073 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4074 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4075 (push txt ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4076 (outline-next-heading))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 ;; Sort the entries by expiration date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4080 (defun org-format-agenda-item (prefix txt &optional category)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 "Format TXT to be inserted into the agenda buffer.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4082 In particular, this indents the line and adds a category."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4083 (let* ((category (or category
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4084 org-category
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4085 (file-name-sans-extension
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4086 (file-name-nondirectory (buffer-file-name)))))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4087 (extra prefix)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4088 (time-of-day (org-get-time-of-day txt))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4089 (t1 (if time-of-day (concat "0" (int-to-string time-of-day)) "0000"))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4090 (time (if time-of-day
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4091 (concat (substring t1 -4 -2)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4092 ":" (substring t1 -2))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4093 ""))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4094 rtn)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4095 (if (symbolp category) (setq category (symbol-name category)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4096 (setq rtn (concat (eval org-prefix-format-compiled) txt))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4097 (add-text-properties
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4098 0 (length rtn) (list 'category (downcase category)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4099 'prefix-length (- (length rtn) (length txt))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4100 'time-of-day time-of-day)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102 rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4103
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4104 (defun org-compile-prefix-format (format)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4105 "Compile the prefix format into a Lisp form that can be evaluated.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4106 The resulting form is returned and stored in the variable
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4107 `org-prefix-format-compiled'."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4108 (let ((start 0) varform vars (s format) c)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4109 (while (string-match "%\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cts]\\)"
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4110 s start)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4111 (setq var (cdr (assoc (match-string 3 s)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4112 '(("c" . category) ("t" . time) ("s" . extra))))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4113 c (match-string 2 s)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4114 start (1+ (match-beginning 0)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4115 (if (= (length c) 1)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4116 (setq varform `(if (equal "" ,var) "" (concat ,var ,c)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4117 (setq varform var))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4118 (setq s (replace-match "%\\1s" t nil s))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4119 (push varform vars))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4120 (setq vars (nreverse vars))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4121 (setq org-prefix-format-compiled `(format ,s ,@vars))))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4122
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4123 (defun org-get-time-of-day (s)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4124 "Check string S for a time of day.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4125 If found, return it as a military time number between 0 and 2400.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4126 If not found, return nil."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4127 (save-match-data
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4128 (when (or
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4129 (string-match
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4130 "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\>" s)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4131 (string-match
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4132 "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\>" s))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4133 (+ (* 100 (+ (string-to-number (match-string 1 s))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4134 (if (and (match-beginning 4)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4135 (equal (downcase (match-string 4 s)) "pm"))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4136 12 0)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4137 (if (match-beginning 3)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4138 (string-to-number (match-string 3 s))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4139 0)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4140
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4141 (defun org-finalize-agenda-entries (list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4142 "Sort and concatenate the agenda items."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4143 (mapconcat 'identity (sort list 'org-entries-lessp) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4144
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4145 (defsubst org-cmp-priority (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4146 "Compare the priorities of string a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4147 (let ((pa (or (get-text-property 1 'priority a) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4148 (pb (or (get-text-property 1 'priority b) 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4149 (cond ((> pa pb) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4150 ((< pa pb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4151 (t nil))))
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 (defsubst org-cmp-category (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4154 "Compare the string values of categories of strings a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4155 (let ((ca (or (get-text-property 1 'category a) ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4156 (cb (or (get-text-property 1 'category b) "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4157 (cond ((string-lessp ca cb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4158 ((string-lessp cb ca) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4159 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4160
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4161 (defsubst org-cmp-time (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4162 "Compare the time-of-day values of strings a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4163 (let* ((def (if org-sort-agenda-notime-is-late 2401 -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4164 (ta (or (get-text-property 1 'time-of-day a) def))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4165 (tb (or (get-text-property 1 'time-of-day b) def)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4166 (cond ((< ta tb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4167 ((< tb ta) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4168 (t nil))))
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-entries-lessp (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4171 "Predicate for sorting agenda entries."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4172 (let* ((time-up (org-cmp-time a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4173 (time-down (if time-up (- time-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4174 (priority-up (org-cmp-priority a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4175 (priority-down (if priority-up (- priority-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4176 (category-up (org-cmp-category a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4177 (category-down (if category-up (- category-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4178 (category-keep (if category-up +1 nil))) ; FIXME +1 or -1?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4179 (cdr (assoc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4180 (eval (cons 'or org-agenda-sorting-strategy))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4181 '((-1 . t) (1 . nil) (nil . nil))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4182
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4183 (defun org-agenda-show-priority ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4184 "Show the priority of the current item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4185 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
4186 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
4187 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4188 (let* ((pri (get-text-property (point-at-bol) 'priority)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4189 (message "Priority is %d" (if pri pri -1000))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4190
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4191 (defun org-agenda-goto (&optional highlight)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4192 "Go to the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4193 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4194 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4195 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4196 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4197 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4198 (switch-to-buffer-other-window buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4199 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4200 (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
4201 (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
4202 (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
4203 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4204 (and (outline-next-heading)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4205 (org-flag-heading nil)))) ; show the next heading
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4206 (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208 (defun org-agenda-switch-to ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 "Go to the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4210 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4213 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (switch-to-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4217 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4218 (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
4219 (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
4220 (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
4221 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4222 (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
4223 (org-flag-heading nil)))))) ; show the next heading
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4224
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4225 (defun org-agenda-goto-mouse (ev)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4226 "Go to the Org-mode file which contains the item at the mouse click."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4227 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4228 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4229 (org-agenda-goto))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4230
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4231 (defun org-agenda-show ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4232 "Display the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4233 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4234 (let ((win (selected-window)))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4235 (org-agenda-goto t)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4236 (select-window win)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4237
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4238 (defun org-agenda-recenter (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4239 "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
4240 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4241 (let ((win (selected-window)))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4242 (org-agenda-goto t)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4243 (recenter arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4244 (select-window win)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4245
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4246 (defun org-agenda-show-mouse (ev)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4247 "Display the Org-mode file which contains the item at the mouse click."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4248 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4249 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4250 (org-agenda-show))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4251
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4252 (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
4253 "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
4254 (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
4255 (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
4256
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4257 (defun org-agenda-error ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4258 (error "Command not allowed in this line."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4259
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4260 (defvar org-last-heading-marker (make-marker)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4261 "Marker pointing to the headline that last changed its TODO state
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4262 by a remote command from the agenda.")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4263
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4264 (defun org-agenda-todo ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4265 "Cycle TODO state of line at point, also in Org-mode file.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4266 This changes the line at point, all other lines in the agenda referring to
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4267 the same tree node, and the headline of the tree node in the Org-mode file."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4269 (org-agenda-check-no-diary)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4270 (let* ((col (current-column))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4271 (marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4272 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4273 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4274 (pos (marker-position marker))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4275 (hdmarker (get-text-property (point) 'org-hd-marker))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4276 (buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4277 newhead)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4278 (with-current-buffer buffer
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4279 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4280 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4281 (org-show-hidden-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4282 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4283 (and (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4284 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4285 (org-todo)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4286 (forward-char 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4287 (setq newhead (org-get-heading))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4288 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4289 (org-back-to-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4290 (move-marker org-last-heading-marker (point))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4291 (beginning-of-line 1)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4292 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4293 (org-agenda-change-all-lines newhead hdmarker 'fixface))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4294 (move-to-column col)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4295
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4296 (defun org-agenda-change-all-lines (newhead hdmarker &optional fixface)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4297 "Change all lines in the agenda buffer which match hdmarker.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4298 The new content of the line will be NEWHEAD. HDMARKER is checked with
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4299 `equal' against all `org-hd-marker' text properties in the file."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4300 (let* (props m pl undone-face done-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4301 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4302 (goto-char (point-max))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4303 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4304 (while (not (bobp))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4305 (when (and (setq m (get-text-property (point) 'org-hd-marker))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4306 (equal m hdmarker))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4307 (setq props (text-properties-at (point))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4308 pl (get-text-property (point) 'prefix-length)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4309 undone-face (get-text-property (point) 'undone-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4310 done-face (get-text-property (point) 'done-face))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4311 (move-to-column pl)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4312 (if (looking-at ".*")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4313 (progn
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4314 (replace-match newhead t t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4315 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4316 (add-text-properties (point-at-bol) (point-at-eol) props)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4317 (if fixface
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4318 (add-text-properties
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4319 (point-at-bol) (point-at-eol)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4320 (list 'face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4321 (if org-last-todo-state-is-todo
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4322 undone-face done-face))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4323 (beginning-of-line 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4324 (error "Line update did not work")))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4325 (beginning-of-line 0)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4326
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4327 (defun org-agenda-priority-up ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4328 "Increase the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4329 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4330 (org-agenda-priority 'up))
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-agenda-priority-down ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4333 "Decrease the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4334 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4335 (org-agenda-priority 'down))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4336
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4337 (defun org-agenda-priority (&optional force-direction)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4338 "Set the priority of line at point, also in Org-mode file.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4339 This changes the line at point, all other lines in the agenda referring to
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4340 the same tree node, and the headline of the tree node in the Org-mode file."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4341 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4342 (org-agenda-check-no-diary)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4343 (let* ((marker (or (get-text-property (point) 'org-marker)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4344 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4345 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4346 (pos (marker-position marker))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4347 (hdmarker (get-text-property (point) 'org-hd-marker))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4348 (buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4349 newhead)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4350 (with-current-buffer buffer
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4351 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4352 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4353 (org-show-hidden-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4354 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4355 (and (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4356 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4357 (funcall 'org-priority force-direction)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4358 (setq newhead (org-get-heading)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4359 (org-agenda-change-all-lines newhead hdmarker)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4360 (beginning-of-line 1)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4361
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4362 (defun org-agenda-date-later (arg &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4363 "Change the date of this item to one day later."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4364 (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
4365 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4366 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4367 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4368 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4369 (pos (marker-position marker)))
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
4370 (with-current-buffer buffer
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4371 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4372 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4373 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4374 (error "Cannot find time stamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4375 (org-timestamp-change arg (or what 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4376 (message "Time stamp changed to %s" org-last-changed-timestamp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4377
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4378 (defun org-agenda-date-earlier (arg &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4379 "Change the date of this item to one day earlier."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4380 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4381 (org-agenda-date-later (- arg) what))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4382
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4383 (defun org-agenda-date-prompt (arg)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4384 "Change the date of this item. Date is prompted for, with default today.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4385 The prefix ARG is passed to the `org-time-stamp' command and can therefore
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4386 be used to request time specification in the time stamp."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4387 (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
4388 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4389 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4390 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4391 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4392 (pos (marker-position marker)))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4393 (with-current-buffer buffer
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4394 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4395 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4396 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4397 (error "Cannot find time stamp"))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4398 (org-time-stamp arg)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4399 (message "Time stamp changed to %s" org-last-changed-timestamp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4400
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4401 (defun org-get-heading ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4402 "Return the heading of the current entry, without the stars."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4403 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4404 (if (and (re-search-backward "[\r\n]\\*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4405 (looking-at "[\r\n]\\*+[ \t]+\\(.*\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4406 (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4407 "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4408
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4409 (defun org-agenda-diary-entry ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4410 "Make a diary entry, like the `i' command from the calendar.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4411 All the standard commands work: block, weekly etc"
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4412 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4413 (require 'diary-lib)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4414 (let* ((char (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4415 (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
4416 (read-char-exclusive)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4417 (cmd (cdr (assoc char
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4418 '((?d . insert-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4419 (?w . insert-weekly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4420 (?m . insert-monthly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4421 (?y . insert-yearly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4422 (?a . insert-anniversary-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4423 (?b . insert-block-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4424 (?c . insert-cyclic-diary-entry)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4425 (oldf (symbol-function 'calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4426 (point (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4427 (mark (or (mark t) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4428 (unless cmd
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4429 (error "No command associated with <%c>" char))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4430 (unless (and (get-text-property point 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4431 (or (not (equal ?b char))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4432 (get-text-property mark 'day)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4433 (error "Don't know which date to use for diary entry"))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4434 ;; We implement this by hacking the `calendar-cursor-to-date' function
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4435 ;; and the `calendar-mark-ring' variable. Saves a lot of code.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4436 (let ((calendar-mark-ring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4437 (list (calendar-gregorian-from-absolute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4438 (or (get-text-property mark 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4439 (get-text-property point 'day))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4440 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4441 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4442 (fset 'calendar-cursor-to-date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4443 (lambda (&optional error)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4444 (calendar-gregorian-from-absolute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4445 (get-text-property point 'day))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4446 (call-interactively cmd))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4447 (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
4448
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4449
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4450 (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
4451 "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
4452 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
4453 (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
4454 (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
4455 (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
4456 (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
4457 (point (point))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4458 (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
4459 (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
4460 (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
4461 (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
4462 (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
4463 (unwind-protect
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4464 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4465 (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
4466 (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
4467 (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
4468 (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
4469 (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
4470 (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
4471
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4472 (defun org-agenda-phases-of-moon ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4473 "Display the phases of the moon for the 3 months around the cursor date."
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4474 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4475 (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
4476
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4477 (defun org-agenda-holidays ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4478 "Display the holidays for the 3 months around the cursor date."
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4479 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4480 (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
4481
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4482 (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
4483 "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
4484 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
4485 `calendar-latitude' and `calendar-longitude'. When called with prefix
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4486 argument, latitude and longitude will be prompted for."
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4487 (interactive "P")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4488 (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
4489 (calendar-latitude (if arg nil calendar-latitude))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4490 (calendar-location-name
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4491 (if arg "the given coordinates" calendar-location-name)))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4492 (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
4493
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4494 (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
4495 "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
4496 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4497 (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
4498 (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
4499 (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
4500 (calendar)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4501 (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
4502
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4503 (defun org-calendar-goto-agenda ()
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4504 "Compute the Org-mode agenda for the calendar date displayed at the cursor.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4505 This is a command that has to be installed in `calendar-mode-map'."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4506 (interactive)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4507 (org-agenda nil (calendar-absolute-from-gregorian
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4508 (calendar-cursor-to-date))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4509
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4510 (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
4511 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4512 (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
4513 date s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4514 (unless day
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4515 (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
4516 (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
4517 (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
4518 "Gregorian: " (calendar-date-string date) "\n"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4519 "ISO: " (calendar-iso-date-string date) "\n"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4520 "Day of Yr: " (calendar-day-of-year-string date) "\n"
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4521 "Julian: " (calendar-julian-date-string date) "\n"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4522 "Astronomic: " (calendar-astro-date-string date)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4523 " (Julian date number at noon UTC)\n"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4524 "Hebrew: " (calendar-hebrew-date-string date) " (until sunset)\n"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4525 "Islamic: " (calendar-islamic-date-string date) " (until sunset)\n"
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4526 "French: " (calendar-french-date-string date) "\n"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4527 "Mayan: " (calendar-mayan-date-string date) "\n"
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4528 "Coptic: " (calendar-coptic-date-string date) "\n"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4529 "Ethiopic: " (calendar-ethiopic-date-string date) "\n"
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4530 "Persian: " (calendar-persian-date-string date) "\n"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4531 "Chinese: " (calendar-chinese-date-string date) "\n"))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4532 (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
4533 (princ s))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4534 (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
4535
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4536 ;;; Link Stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4537
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4538 (defun org-find-file-at-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4539 "Open file link or URL at mouse."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4540 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4541 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4542 (org-open-at-point 'in-emacs))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4543
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4544 (defun org-open-at-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4545 "Open file link or URL at mouse."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4546 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4547 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4548 (org-open-at-point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4549
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4550 (defun org-open-at-point (&optional in-emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4551 "Open link at or after point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4552 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
4553 the end of the current subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4554 Normally, files will be opened by an appropriate application. If the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4555 optional argument IN-EMACS is non-nil, Emacs will visit the file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4556 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4557 (if (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4558 (org-agenda nil (time-to-days (org-time-string-to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4559 (substring (match-string 1) 0 10)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4560 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4561 (let (type path line (pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4562 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4563 (skip-chars-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4564 (if org-allow-space-in-links "^\t\n\r" "^ \t\n\r"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4565 (if (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4566 org-link-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4567 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4568 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4569 (progn (outline-end-of-subtree) (max pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4570 (error (end-of-line 1) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4571 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4572 (setq type (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4573 path (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4574 (unless path
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4575 (error "No link found."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4576 ;; Remove any trailing spaces in path
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4577 (if (string-match " +\\'" path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4578 (setq path (replace-match "" t t path)))
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 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4581
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4582 ((string= type "file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4583 (if (string-match ":\\([0-9]+\\)\\'" path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4584 (setq line (string-to-number (match-string 1 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4585 path (substring path 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4586 (org-open-file path in-emacs line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4587
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4588 ((string= type "news")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4589 (org-follow-gnus-link path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4590
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4591 ((string= type "bbdb")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4592 (org-follow-bbdb-link path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4593
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4594 ((string= type "gnus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4595 (let (group article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4596 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4597 (error "Error in Gnus link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4598 (setq group (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4599 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4600 (org-follow-gnus-link group article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4601
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4602 ((string= type "vm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4603 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4604 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4605 (error "Error in VM link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4606 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4607 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4608 ;; in-emacs is the prefix arg, will be interpreted as read-only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4609 (org-follow-vm-link folder article in-emacs)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4610
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4611 ((string= type "wl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4612 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4613 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4614 (error "Error in Wanderlust link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4615 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4616 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4617 (org-follow-wl-link folder article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4618
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4619 ((string= type "rmail")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4620 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4621 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4622 (error "Error in RMAIL link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4623 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4624 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4625 (org-follow-rmail-link folder article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4626
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4627 ((string= type "shell")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4628 (let ((cmd path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4629 (if (or (not org-confirm-shell-links)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4630 (yes-or-no-p (format "Execute \"%s\" in the shell? " cmd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4631 (shell-command cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4632 (error "Abort"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4633
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4634 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4635 (browse-url-at-point)))))))
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 (defun org-follow-bbdb-link (name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4638 "Follow a BBDB link to NAME."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4639 (require 'bbdb)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4640 (let ((inhibit-redisplay t))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4641 (catch 'exit
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4642 ;; Exact match on name
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4643 (bbdb-name (concat "\\`" name "\\'") nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4644 (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4645 ;; Exact match on name
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4646 (bbdb-company (concat "\\`" name "\\'") nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4647 (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4648 ;; Partial match on name
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4649 (bbdb-name name nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4650 (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4651 ;; Partial match on company
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4652 (bbdb-company name nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4653 (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4654 ;; General match including network address and notes
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4655 (bbdb name nil)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4656 (when (= 0 (buffer-size (get-buffer "*BBDB*")))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4657 (delete-window (get-buffer-window "*BBDB*"))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4658 (error "No matching BBDB record")))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4659
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4660 (defun org-follow-gnus-link (&optional group article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4661 "Follow a Gnus link to GROUP and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4662 (require 'gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4663 (funcall (cdr (assq 'gnus org-link-frame-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4664 (if group (gnus-fetch-group group))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4665 (if article
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4666 (or (gnus-summary-goto-article article nil 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4667 (if (fboundp 'gnus-summary-insert-cached-articles)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4668 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4669 (gnus-summary-insert-cached-articles)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4670 (gnus-summary-goto-article article nil 'force))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4671 (message "Message could not be found.")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4672
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4673 (defun org-follow-vm-link (&optional folder article readonly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4674 "Follow a VM link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4675 (require 'vm)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4676 (if (string-match "^//\\([a-zA-Z]+@\\)?\\([^:]+\\):\\(.*\\)" folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4677 ;; ange-ftp or efs or tramp access
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4678 (let ((user (or (match-string 1 folder) (user-login-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4679 (host (match-string 2 folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4680 (file (match-string 3 folder)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4681 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4682 ((featurep 'tramp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4683 ;; use tramp to access the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4684 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4685 (setq folder (format "[%s@%s]%s" user host file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4686 (setq folder (format "/%s@%s:%s" user host file))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4687 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4688 ;; use ange-ftp or efs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4689 (require (if org-xemacs-p 'efs 'ange-ftp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4690 (setq folder (format "/%s@%s:%s" user host file))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4691 (when folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4692 (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4693 (sit-for 0.1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4694 (when article
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4695 (vm-select-folder-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4696 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4697 (let ((case-fold-search t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4698 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4699 (if (not (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4700 (concat "^" "message-id: *" (regexp-quote article))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4701 (error "Could not find the specified message in this folder"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4702 (vm-isearch-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4703 (vm-isearch-narrow)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4704 (vm-beginning-of-message)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4705 (vm-summarize)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4706
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4707 (defun org-follow-wl-link (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4708 "Follow a Wanderlust link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4709 (wl-summary-goto-folder-subr folder 'no-sync t nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4710 (if article (wl-summary-jump-to-msg-by-message-id article))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4711 (wl-summary-redisplay))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4712
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4713 (defun org-follow-rmail-link (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4714 "Follow an RMAIL link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4715 (let (message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4716 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4717 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4718 (rmail (if (string= folder "RMAIL") rmail-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4719 (setq message-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4720 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4721 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4722 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4723 (if (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4724 (concat "^Message-ID:\\s-+" (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4725 (or article "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4726 nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4727 (rmail-what-message))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4728 (if message-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4729 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4730 (rmail (if (string= folder "RMAIL") rmail-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4731 (rmail-show-message message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4732 message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4733 (error "Message not found"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4734
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4735 (defun org-open-file (path &optional in-emacs line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4736 "Open the file at PATH.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4737 First, this expands any special file name abbreviations. Then the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4738 configuration variable `org-file-apps' is checked if it contains an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4739 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
4740 If no application is found, Emacs simply visits the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4741 With optional argument IN-EMACS, Emacs will visit the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4742 If the file does not exist, an error is thrown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4743 (let* ((file (convert-standard-filename (org-expand-file-name path)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4744 (dfile (downcase file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4745 ext cmd apps)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4746 (if (and (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4747 (not org-open-non-existing-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4748 (error "No such file: %s" file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4749 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\.gz\\)$" dfile)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4750 (setq ext (match-string 1 dfile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4751 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4752 (setq ext (match-string 1 dfile))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4753 (setq apps (append org-file-apps (org-default-apps)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4754 (if in-emacs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4755 (setq cmd 'emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4756 (setq cmd (or (cdr (assoc ext apps))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4757 (cdr (assoc t apps)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4758 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4759 ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4760 (setq cmd (format cmd file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4761 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4762 (shell-command (concat cmd " & &"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4763 ((or (stringp cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4764 (eq cmd 'emacs))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4765 (funcall (cdr (assq 'file org-link-frame-setup)) file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4766 (if line (goto-line line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4767 ((consp cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4768 (eval cmd))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4769 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4770
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4771 (defun org-default-apps ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4772 "Return the default applications for this operating system."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4773 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4774 ((eq system-type 'darwin)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4775 org-file-apps-defaults-macosx)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4776 ((eq system-type 'windows-nt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4777 org-file-apps-defaults-windowsnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4778 ((eq system-type 'linux)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4779 org-file-apps-defaults-linux)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4780 (t org-file-apps-defaults-linux)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4781
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4782 (defun org-expand-file-name (path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4783 "Replace special path abbreviations and expand the file name."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4784 (expand-file-name path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4785
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4786
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4787 (defvar org-insert-link-history nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4788 "Minibuffer history for links inserted with `org-insert-link'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4789
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4790 (defvar org-stored-links nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4791 "Contains the links stored with `org-store-link'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4792
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-store-link (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4795 "\\<org-mode-map>Store an org-link to the current location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4796 This link can later be inserted into an org-buffer with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4797 \\[org-insert-link].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4798 For some link types, a prefix arg is interpreted:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4799 For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4800 For file links, arg negates `org-line-numbers-in-file-links'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4801 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4802 (let (link cpltxt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4803 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4804
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4805 ((eq major-mode 'bbdb-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4806 (setq link (concat "bbdb:"
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4807 (or (bbdb-record-name (bbdb-current-record))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4808 (bbdb-record-company (bbdb-current-record))))))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4809
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4810 ((eq major-mode 'calendar-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4811 (let ((cd (calendar-cursor-to-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4812 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4813 (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4814 (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4815 (apply 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4816 (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
4817 nil nil nil))))))
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 ((or (eq major-mode 'vm-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4820 (eq major-mode 'vm-presentation-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4821 (and (eq major-mode 'vm-presentation-mode) (vm-summarize))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4822 (vm-follow-summary-cursor)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4823 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4824 (vm-select-folder-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4825 (let* ((message (car vm-message-pointer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4826 (folder (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4827 (subject (vm-su-subject message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4828 (author (vm-su-full-name message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4829 (message-id (vm-su-message-id message)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4830 (setq folder (abbreviate-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4831 (if (string-match (concat "^" (regexp-quote vm-folder-directory))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4832 folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4833 (setq folder (replace-match "" t t folder)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4834 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4835 (setq link (concat cpltxt "\n " "vm:" folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4836 "#" message-id)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4837
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4838 ((eq major-mode 'wl-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4839 (let* ((msgnum (wl-summary-message-number))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4840 (message-id (elmo-message-field wl-summary-buffer-elmo-folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4841 msgnum 'message-id))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4842 (wl-message-entity (elmo-msgdb-overview-get-entity
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4843 msgnum (wl-summary-buffer-msgdb)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4844 (author (wl-summary-line-from)) ; FIXME: how to get author name?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4845 (subject "???")) ; FIXME: How to get subject of email?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4846 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4847 (setq link (concat cpltxt "\n " "wl:" wl-summary-buffer-folder-name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4848 "#" message-id))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4849
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4850 ((eq major-mode 'rmail-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4851 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4852 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4853 (rmail-narrow-to-non-pruned-header)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4854 (let ((folder (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4855 (message-id (mail-fetch-field "message-id"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4856 (author (mail-fetch-field "from"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4857 (subject (mail-fetch-field "subject")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4858 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4859 (setq link (concat cpltxt "\n " "rmail:" folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4860 "#" message-id))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4861
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4862 ((eq major-mode 'gnus-group-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4863 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4864 (gnus-group-group-name)) ; version
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4865 ((fboundp 'gnus-group-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4866 (gnus-group-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4867 (t "???"))))
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
4868 (setq link (concat (if (org-xor arg org-usenet-links-prefer-google)
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
4869 "http://groups.google.com/groups?group="
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
4870 "gnus:")
62087
fab4f3bb60e0 (org-store-link): Fix paren typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 62076
diff changeset
4871 group))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4872
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4873 ((memq major-mode '(gnus-summary-mode gnus-article-mode))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4874 (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4875 (gnus-summary-beginning-of-article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4876 (let* ((group (car gnus-article-current))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4877 (article (cdr gnus-article-current))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4878 (header (gnus-summary-article-header article))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4879 (author (mail-header-from header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4880 (message-id (mail-header-id header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4881 (date (mail-header-date header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4882 (subject (gnus-summary-subject-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4883 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4884 (if (org-xor arg org-usenet-links-prefer-google)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4885 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4886 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4887 cpltxt "\n "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4888 (format "http://groups.google.com/groups?as_umsgid=%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4889 (org-fixup-message-id-for-http message-id))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4890 (setq link (concat cpltxt "\n" "gnus:" group
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4891 "#" (number-to-string article))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4892
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4893 ((eq major-mode 'w3-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4894 (setq link (url-view-url t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4895 ((eq major-mode 'w3m-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 (setq link w3m-current-url))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4897
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4898 ((buffer-file-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4899 ;; Just link to this file here.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4900 (setq link (concat "file:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4901 (abbreviate-file-name (buffer-file-name))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4902 ;; Add the line number?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4903 (if (org-xor org-line-numbers-in-file-links arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4904 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4905 (concat link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4906 ":" (int-to-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4907 (+ (if (bolp) 1 0) (count-lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4908 (point-min) (point))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4909 ((interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4910 (error "Cannot link to a buffer which is not visiting a file"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4911 (t (setq link nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4912
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4913 (if (and (interactive-p) link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4914 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4915 (setq org-stored-links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4916 (cons (cons (or cpltxt link) link) org-stored-links))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 (message "Stored: %s" (or cpltxt link)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4918 link)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4919
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4920 (defun org-xor (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4921 "Exclusive or."
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
4922 ;; (if a (not b) b)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4923 (or (and a (not b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924 (and b (not a))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4925
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4926 (defun org-get-header (header)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4927 "Find a header field in the current buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4928 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4929 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4930 (let ((case-fold-search t) s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4931 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4932 ((eq header 'from)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4933 (if (re-search-forward "^From:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4934 (setq s (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4935 (while (string-match "\"" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936 (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4937 (if (string-match "[<(].*" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4938 (setq s (replace-match "" t t s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4939 ((eq header 'message-id)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4940 (if (re-search-forward "^message-id:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4941 (setq s (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4942 ((eq header 'subject)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4943 (if (re-search-forward "^subject:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4944 (setq s (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4945 (if (string-match "\\`[ \t\]+" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4946 (if (string-match "[ \t\]+\\'" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4947 s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4948
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 (defun org-fixup-message-id-for-http (s)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4951 "Replace special characters in a message id, so it can be used in an http query."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4952 (while (string-match "<" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4953 (setq s (replace-match "%3C" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4954 (while (string-match ">" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4955 (setq s (replace-match "%3E" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4956 (while (string-match "@" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4957 (setq s (replace-match "%40" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4958 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4959
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4960 (defun org-insert-link (&optional complete-file)
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
4961 "Insert a link. At the prompt, enter the link.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4962
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4963 Completion can be used to select a link previously stored with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4964 `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
4965 press RET at the prompt), the link defaults to the most recently
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4966 stored link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4967
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4968 With a \\[universal-argument] prefix, prompts for a file to link to. The file name can be
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4969 selected using completion. The path to the file will be relative to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4970 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
4971 subdirectory. Otherwise, the link will be the absolute path as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4972 completed in the minibuffer (i.e. normally ~/path/to/file).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4973
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
4974 With two \\[universal-argument] prefixes, enforce an absolute path even if the file
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4975 is in the current directory or below."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4976 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4977 (let ((link (if complete-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4978 (read-file-name "File: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4979 (completing-read
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4980 "Link: " org-stored-links nil nil nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4981 org-insert-link-history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4982 (or (car (car org-stored-links))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4983 linktxt matched)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4984 (if (or (not link) (equal link ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985 (error "No links available"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4986 (if complete-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4987 (let ((pwd (file-name-as-directory (expand-file-name "."))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4988 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4989 ((equal complete-file '(16))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4990 (insert "file:" (abbreviate-file-name (expand-file-name link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4991 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4992 (expand-file-name link))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4993 (insert "file:" (match-string 1 (expand-file-name link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4994 (t (insert "file:" link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4995 (setq linktxt (cdr (assoc link org-stored-links)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4996 (if (not org-keep-stored-link-after-insertion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4997 (setq org-stored-links (delq (assoc link org-stored-links)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4998 org-stored-links)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4999 (let ((lines (org-split-string (or linktxt link) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5000 (insert (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5001 (setq matched (string-match org-link-regexp (car lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5002 (setq lines (cdr lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5003 (while lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5004 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5005 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5006 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5007 (looking-at "[ \t]+\\S-"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5008 (indent-relative))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5009 (setq matched (or matched
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5010 (string-match org-link-regexp (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5011 (insert (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5012 (setq lines (cdr lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5013 (unless matched
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5014 (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
5015
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5016 ;;; Hooks for remember.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5017 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5018 (defun org-remember-annotation ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5019 "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
5020 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
5021 remember.el, then the annotations should include a link compatible with the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5022 conventions in Org-mode. This function returns such a link."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023 (org-store-link nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5025 (defconst org-remember-help
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5026 "Select a destination location for the note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5027 UP/DOWN=headline TAB=cycle visibility [Q]uit RET/<left>/<right>=Store
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028 RET at beg-of-buf -> Append to file as level 2 headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029 RET on headline -> Store as sublevel entry to current headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5030 <left>/<right> -> before/after current headline, same headings level")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5031
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5032 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5033 (defun org-remember-handler ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5034 "Store stuff from remember.el into an org file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5035 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
5036 of `org-default-notes-file' is used.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5037 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
5038 file the text at a specific location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5039 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
5040 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
5041 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
5042
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5043 Key Cursor position Note gets inserted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5044 -----------------------------------------------------------------------------
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5045 RET buffer-start as level 2 heading at end of file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5046 RET on headline as sublevel of the heading at cursor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5047 RET no heading at cursor position, level taken from context.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5048 Or use prefix arg to specify level manually.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5049 <left> on headline as same level, before current heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5050 <right> on headline as same level, after current heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5051
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5052 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
5053 the default file. This way your current train of thought is not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5054 interrupted, in accordance with the principles of remember.el. But with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5055 little extra effort, you can push it directly to the correct location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5056
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5057 Before being stored away, the function ensures that the text has a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5058 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
5059 is constructed from the current date and some additional data.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5060
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5061 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
5062 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
5063 \(i.e. after the stars).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5064
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5065 See also the variable `org-reverse-note-order'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5066 (catch 'quit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5067 (let* ((txt (buffer-substring (point-min) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5068 (fastp current-prefix-arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5069 (file (if fastp org-default-notes-file (org-get-org-file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5070 (visiting (find-buffer-visiting file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5071 (org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5072 (org-startup-folded nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5073 spos level indent reversed)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5074 ;; 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
5075 ;; into an org tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5076 (let* ((lines (split-string txt "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5077 (first (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5078 (lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5079 (if (string-match "^\\*+" first)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5080 ;; Is already a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5081 (setq indent (make-string (- (match-end 0) (match-beginning 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5082 -1) ?\ ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5083 ;; We need to add a headline: Use time and first buffer line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5084 (setq lines (cons first lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5085 first (concat "* " (current-time-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5086 " (" (remember-buffer-desc) ")")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5087 indent " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5088 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5089 (setq lines (mapcar (lambda (x) (concat indent x)) lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5090 (setq txt (concat first "\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5091 (mapconcat 'identity lines "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5092 ;; Find the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5093 (if (not visiting)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5094 (find-file-noselect file))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5095 (with-current-buffer (get-file-buffer file)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5096 (setq reversed (org-notes-order-reversed-p))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5097 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5098 (save-restriction
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5099 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5100 ;; Ask the User for a location
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5101 (setq spos (if fastp 1 (org-get-location
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5102 (current-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5103 org-remember-help)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5104 (if (not spos) (throw 'quit nil)) ; return nil to show we did
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5105 ; not handle this note
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5106 (goto-char spos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5107 (cond ((bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5108 ;; Put it at the start or end, as level 2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5109 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5110 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5111 (goto-char (if reversed (point-min) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5112 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5113 (org-paste-subtree (or current-prefix-arg 2) txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5114 ((and (org-on-heading-p nil) (not current-prefix-arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5115 ;; Put it below this entry, at the beg/end of the subtree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5116 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5117 (setq level (outline-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5118 (if reversed
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5119 (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5120 (outline-end-of-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5121 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5122 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5123 (org-paste-subtree (1+ level) txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5124 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5125 ;; Put it right there, with automatic level determined by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5126 ;; org-paste-subtree or from prefix arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5127 (org-paste-subtree current-prefix-arg txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5128 (when remember-save-after-remembering
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5129 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5130 (if (not visiting) (kill-buffer (current-buffer)))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5131 t) ;; return t to indicate that we took care of this note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5132
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5133 (defun org-get-org-file ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5134 "Read a filename, with default directory `org-directory'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5135 (let ((default (or org-default-notes-file remember-data-file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5136 (read-file-name (format "File name [%s]: " default)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5137 (file-name-as-directory org-directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5138 default)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5139
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5140 (defun org-notes-order-reversed-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5141 "Check if the current file should receive notes in reversed order."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5142 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5143 ((not org-reverse-note-order) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5144 ((eq t org-reverse-note-order) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5145 ((not (listp org-reverse-note-order)) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5146 (t (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5147 (let ((all org-reverse-note-order)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5148 entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5149 (while (setq entry (pop all))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5150 (if (string-match (car entry) (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5151 (throw 'exit (cdr entry))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5152 nil)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5153
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5154 ;;; Tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5155
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5156 ;; Watch out: Here we are talking about two different kind of tables.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5157 ;; 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
5158 ;; Sometimes, we talk about tables created and edited with the table.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5159 ;; Emacs package. We call the former org-type tables, and the latter
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5160 ;; table.el-type tables.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5161
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5162
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5163 (defun org-before-change-function (beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5164 "Every change indicates that a table might need an update."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5165 (setq org-table-may-need-update t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5166
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5167 (defconst org-table-line-regexp "^[ \t]*|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5168 "Detects an org-type table line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5169 (defconst org-table-dataline-regexp "^[ \t]*|[^-]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5170 "Detects an org-type table line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5171 (defconst org-table-hline-regexp "^[ \t]*|-"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5172 "Detects an org-type table hline.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5173 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5174 "Detects a table-type table hline.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5175 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)"
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5176 "Detects an org-type or table-type table.")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5177 (defconst org-table-border-regexp "^[ \t]*[^| \t]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5178 "Searching from within a table (any type) this finds the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5179 outside the table.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5180 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5181 "Searching from within a table (any type) this finds the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5182 outside the table.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5183
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5184 (defun org-table-create-with-table.el ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5185 "Use the table.el package to insert a new table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5186 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
5187 and table.el tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5188 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5189 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5190 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5191 ((org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5192 (if (y-or-n-p "Convert table to Org-mode table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5193 (org-table-convert)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5194 ((org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5195 (if (y-or-n-p "Convert table to table.el table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5196 (org-table-convert)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5197 (t (call-interactively 'table-insert))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5198
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5199 (defun org-table-create (&optional size)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5200 "Query for a size and insert a table skeleton.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5201 SIZE is a string Columns x Rows like for example \"3x2\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5202 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5203 (unless size
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5204 (setq size (read-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5205 (concat "Table size Columns x Rows [e.g. "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5206 org-table-default-size "]: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5207 "" nil org-table-default-size)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5208
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5209 (let* ((pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5210 (indent (make-string (current-column) ?\ ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5211 (split (org-split-string size " *x *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5212 (rows (string-to-number (nth 1 split)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5213 (columns (string-to-number (car split)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5214 (line (concat (apply 'concat indent "|" (make-list columns " |"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5215 "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5216 (if (string-match "^[ \t]*$" (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5217 (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5218 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5219 (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5220 (mapcar (lambda (x) (insert line)) (make-list rows t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5221 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5222 (if (> rows 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5223 ;; Insert a hline after the first row.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5224 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5225 (end-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5226 (insert "\n|-")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5227 (goto-char pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5228 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5229
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5230 (defun org-table-convert-region (beg0 end0 nspace)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5231 "Convert region to a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5232 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
5233 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
5234 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
5235 separate columns (default: just one space)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5236 (let* ((beg (min beg0 end0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5237 (end (max beg0 end0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5238 (tabsep t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5239 re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5240 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5241 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5242 (setq beg (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5243 (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5244 (if (bolp) (backward-char 1) (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5245 (setq end (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5246 ;; Lets see if this is tab-separated material. If every nonempty line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5247 ;; contains a tab, we will assume that it is tab-separated material
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5248 (if nspace
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5249 (setq tabsep nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5250 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5251 (and (re-search-forward "^[^\n\t]+$" end t) (setq tabsep nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5252 (if nspace (setq tabsep nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5253 (if tabsep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5254 (setq re "^\\|\t")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5255 (setq re (format "^ *\\| *\t *\\| \\{%d,\\}"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5256 (max 1 (prefix-numeric-value nspace)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5257 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5258 (while (re-search-forward re end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5259 (replace-match "|" t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5260 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5261 (insert " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5262 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5263
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5264 (defun org-table-import (file arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5265 "Import FILE as a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5266 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
5267 spreadsheet and database applications. If no tabs (at least one per line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5268 are found, lines will be split on whitespace into fields."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5269 (interactive "f\nP")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5270 (or (bolp) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5271 (let ((beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5272 (pm (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5273 (insert-file-contents file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5274 (org-table-convert-region beg (+ (point) (- (point-max) pm)) arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5275
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5276 (defun org-table-export ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5277 "Export table as a tab-separated file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5278 Such a file can be imported into a spreadsheet program like Excel."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5279 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5280 (let* ((beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5281 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5282 (table (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5283 (file (read-file-name "Export table to: "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5284 buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5285 (unless (or (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5286 (y-or-n-p (format "Overwrite file %s? " file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5287 (error "Abort"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5288 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5289 (find-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5290 (setq buf (current-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5291 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5292 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5293 (insert table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5294 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5295 (while (re-search-forward "^[ \t]*|[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5296 (replace-match "" t t)
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 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5299 (while (re-search-forward "[ \t]*|[ \t]*$" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5300 (replace-match "" t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5301 (goto-char (min (1+ (point)) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5302 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5303 (while (re-search-forward "^-[-+]*$" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5304 (replace-match "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5305 (if (looking-at "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5306 (delete-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5307 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5308 (while (re-search-forward "[ \t]*|[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5309 (replace-match "\t" t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5310 (save-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5311 (kill-buffer buf)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5312
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5313 (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
5314 "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
5315 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
5316 (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
5317 "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
5318 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
5319 (defvar org-table-last-alignment nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5320 "List of flags for flushright alignment, from the last re-alignment.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5321 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
5322 ;; 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
5323 (defvar org-table-last-column-widths nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5324 "List of max width of fields in each column.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5325 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
5326
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5327
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5328 (defun org-table-align ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5329 "Align the table at point by aligning all vertical bars."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5330 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5331 (let* (
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5332 ;; Limits of table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5333 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5334 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5335 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5336 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5337 (colpos (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5338 (winstart (window-start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5339 text lines (new "") lengths l typenums ty fields maxfields i
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5340 column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5341 (indent "") cnt frac
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5342 rfmt hfmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5343 (spaces (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5344 org-table-spaces-around-invisible-separators
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5345 org-table-spaces-around-separators))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5346 (sp1 (car spaces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5347 (sp2 (cdr spaces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5348 (rfmt1 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5349 (make-string sp2 ?\ ) "%%%s%ds" (make-string sp1 ?\ ) "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5350 (hfmt1 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5351 (make-string sp2 ?-) "%s" (make-string sp1 ?-) "+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5352 emptystrings)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5353 (untabify beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5354 ;; (message "Aligning table...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5355 ;; Get the rows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5356 (setq lines (org-split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5357 (buffer-substring-no-properties beg end) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5358 ;; Store the indentation of the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5359 (if (string-match "^ *" (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5360 (setq indent (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5361 ;; Mark the hlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5362 (setq lines (mapcar (lambda (l) (if (string-match "^ *|-" l) nil l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5363 lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5364 ;; Get the data fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5365 (setq fields (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5366 (lambda (l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5367 (org-split-string l " *| *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5368 (delq nil (copy-sequence lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5369 ;; How many fields in the longest line?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5370 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5371 (setq maxfields (apply 'max (mapcar 'length fields)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5372 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5373 (kill-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5374 (org-table-create org-table-default-size)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5375 (error "Empty table - created default table")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5376 ;; A list of empty string to fill any short rows on output
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5377 (setq emptystrings (make-list maxfields ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5378 ;; Get the maximum length of a field and the most common datatype
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5379 ;; for each column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5380 (setq i -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5381 (while (< (setq i (1+ i)) maxfields) ;; Loop over all columns
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5382 (setq column (mapcar (lambda (x) (or (nth i x) "")) fields))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5383 ;; maximum length
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5384 (push (apply 'max 1 (mapcar 'length column)) lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5385 ;; compute the fraction stepwise, ignoring empty fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5386 (setq cnt 0 frac 0.0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5387 (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5388 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5389 (if (equal x "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5390 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5391 (setq frac ( / (+ (* frac cnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5392 (if (string-match org-table-number-regexp x) 1 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5393 (setq cnt (1+ cnt))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5394 column)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5395 (push (>= frac org-table-number-fraction) typenums))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5396 (setq lengths (nreverse lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5397 typenums (nreverse typenums))
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5398 (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
5399 org-table-last-column-widths lengths)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5400 ;; Compute the formats needed for output of the table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5401 (setq rfmt (concat indent "|") hfmt (concat indent "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5402 (while (setq l (pop lengths))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403 (setq ty (if (pop typenums) "" "-")) ; number types flushright
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5404 (setq rfmt (concat rfmt (format rfmt1 ty l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5405 hfmt (concat hfmt (format hfmt1 (make-string l ?-)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5406 (setq rfmt (concat rfmt "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5407 hfmt (concat (substring hfmt 0 -1) "|\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 ;; Produce the new table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5409 (while lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5410 (setq l (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411 (if l
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5412 (setq new (concat new (apply 'format rfmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5413 (append (pop fields) emptystrings))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5414 (setq new (concat new hfmt))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5415 ;; Replace the old one
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5416 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5417 (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
5418 (move-marker org-table-aligned-begin-marker (point))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419 (insert new)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5420 (move-marker org-table-aligned-end-marker (point))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5421 ;; Try to move to the old location (approximately)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5422 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5423 (set-window-start (selected-window) winstart 'noforce)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5424 (org-table-goto-column colpos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (setq org-table-may-need-update nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5426 (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5427 (org-table-add-invisible-to-vertical-lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5428 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5429
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5430 (defun org-table-begin (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5431 "Find the beginning of the table and return its position.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5432 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
5433 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5434 (if (not (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5435 (if table-type org-table-any-border-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5436 org-table-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5437 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5438 (error "Can't find beginning of table")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5439 (goto-char (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5440 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5441 (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5442
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5443 (defun org-table-end (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5444 "Find the end of the table and return its position.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5445 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
5446 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5447 (if (not (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5448 (if table-type org-table-any-border-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5449 org-table-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5450 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5451 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5452 (goto-char (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5453 (point-marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5454
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5455 (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
5456 "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
5457 (cond
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5458 (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
5459 ((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
5460 ;; 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
5461 (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
5462 ((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
5463 (current-buffer)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5464 (< (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
5465 (>= (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
5466 ;; 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
5467 (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
5468 (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
5469 (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
5470 (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
5471 (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
5472 l f)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5473 (when (> col 0)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5474 (skip-chars-backward "^|\n")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5475 (if (looking-at " *\\([^|\n]*?\\) *|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5476 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5477 (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
5478 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
5479 (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
5480 (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
5481 (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
5482 (goto-char pos))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5483
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5484 (defun org-table-next-field ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5485 "Go to the next field in the current table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5486 Before doing so, re-align the table if necessary."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5487 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5488 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5490 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5491 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5492 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5493 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5494 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5495 (re-search-forward "|" (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5496 (if (looking-at "[ \t]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5497 (re-search-forward "|" (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5498 (if (looking-at "-")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5499 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5500 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5501 (org-table-insert-row 'below))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5502 (if (looking-at " ") (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5503 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5504 (org-table-insert-row 'below))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5505
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5506 (defun org-table-previous-field ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5507 "Go to the previous field in the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5508 Before doing so, re-align the table if necessary."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5509 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5510 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5511 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5512 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5513 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5514 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5515 (re-search-backward "|" (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5516 (re-search-backward "|" (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5517 (while (looking-at "|\\(-\\|[ \t]*$\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5518 (re-search-backward "|" (org-table-begin)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5519 (if (looking-at "| ?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5520 (goto-char (match-end 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5521
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5522 (defun org-table-next-row ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5523 "Go to the next row (same column) in the current table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5524 Before doing so, re-align the table if necessary."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5525 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5526 (if (or (looking-at "[ \t]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5527 (save-excursion (skip-chars-backward " \t") (bolp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5528 (newline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5529 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5530 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5531 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5532 (let ((col (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5533 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5534 (if (or (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5535 (org-at-table-hline-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5536 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5537 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5538 (org-table-insert-row 'below)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5539 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5540 (skip-chars-backward "^|\n\r")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5541 (if (looking-at " ") (forward-char 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5542
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5543 (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
5544 "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
5545 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
5546 non-empty field above. With argument N, use the Nth non-empty field.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5547 If the current field is not empty, it is copied down to the next row, and
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5548 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
5549 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
5550 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
5551 integer, it will be incremented while copying."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5552 (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
5553 (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
5554 (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
5555 (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
5556 (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
5557 txt)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5558 (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
5559 (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
5560 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5561 (setq txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5562 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5563 (while (progn (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5564 (re-search-backward org-table-dataline-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5565 beg t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5566 (org-table-goto-column colpos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5567 (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
5568 "|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5569 (= (setq n (1- n)) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5570 (throw 'exit (match-string 1)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5571 (progn
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5572 (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
5573 (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
5574 (setq txt (format "%d" (+ (string-to-int txt) 1))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5575 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5577 (error "No non-empty field found"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5578
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5579 (defun org-table-check-inside-data-field ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5580 "Is point inside a table data field?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 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
5582 (if (or (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5583 (= (org-table-current-column) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5584 (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5585 (looking-at "[ \t]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5586 (error "Not in table data field")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5587
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5588 (defvar org-table-clip nil
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
5589 "Clipboard for table regions.")
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5590
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5591 (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
5592 "Blank the current table field or active region."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5593 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5594 (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
5595 (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
5596 (let (org-table-clip)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5597 (org-table-cut-region))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5598 (skip-chars-backward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5599 (backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5600 (if (looking-at "|[^|]+")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5601 (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
5602 (match (match-string 0))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5603 (len (length match)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5604 (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
5605 (goto-char (+ 2 pos))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5606 (substring match 1)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5607
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5608 (defun org-table-get-field (&optional n replace)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5609 "Return the value of the field in column N of current row.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5610 N defaults to current field.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5611 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
5612 is always the old value."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5613 (and n (org-table-goto-column n))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5614 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5615 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5616 (if (looking-at "|[^|\r\n]*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5617 (let* ((pos (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5618 (val (buffer-substring (1+ pos) (match-end 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5619 (if replace
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5620 (replace-match (concat "|" replace)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5621 (goto-char (+ 2 pos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5622 val)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5623
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5624 (defun org-table-current-column ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5625 "Find out which column we are in.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5626 When called interactively, column is also displayed in echo area."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5627 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5628 (if (interactive-p) (org-table-check-inside-data-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5629 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5630 (let ((cnt 0) (pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5631 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5632 (while (search-forward "|" pos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5633 (setq cnt (1+ cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5634 (if (interactive-p) (message "This is table column %d" cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5635 cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5636
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5637 (defun org-table-goto-column (n &optional on-delim force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5638 "Move the cursor to the Nth column in the current table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5639 With optional argument ON-DELIM, stop with point before the left delimiter
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5640 of the field.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5641 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
5642 However, when FORCE is non-nil, create new columns if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5643 (let ((pos (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5644 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5645 (when (> n 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5646 (while (and (> (setq n (1- n)) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5647 (or (search-forward "|" pos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5648 (and force
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5649 (progn (end-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5650 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5651 (insert " |")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5652 (backward-char 2) t)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5653 (when (and force (not (looking-at ".*|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5654 (save-excursion (end-of-line 1) (insert "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5655 (if on-delim
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5656 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5657 (if (looking-at " ") (forward-char 1))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5658
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5659 (defun org-at-table-p (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5660 "Return t if the cursor is inside an org-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5661 (if org-enable-table-editor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5662 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5663 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5664 (looking-at (if table-type org-table-any-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5665 org-table-line-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5666 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5667
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5668 (defun org-table-recognize-table.el ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5669 "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
5670 (if org-table-tab-recognizes-table.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5671 (if (org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5672 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5673 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5674 (if (looking-at org-table-dataline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5675 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5676 (if (looking-at org-table1-hline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5677 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5678 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5679 (if (looking-at org-table-any-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5680 (beginning-of-line -1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5681 (if (re-search-forward "|" (org-table-end t) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5682 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5683 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5684 (if (table--at-cell-p (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5685 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5686 (message "recognizing table.el table...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5687 (table-recognize-table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5688 (message "recognizing table.el table...done")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5689 (error "This should not happen..."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5690 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5691 nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5692 nil))
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 (defun org-at-table.el-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5695 "Return t if the cursor is inside a table.el-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5696 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5697 (if (org-at-table-p 'any)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5698 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5699 (goto-char (org-table-begin 'any))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5700 (looking-at org-table1-hline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5701 nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5702
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5703 (defun org-at-table-hline-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5704 "Return t if the cursor is inside a hline in a table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5705 (if org-enable-table-editor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5706 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5707 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5708 (looking-at org-table-hline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5709 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5710
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5711 (defun org-table-insert-column ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5712 "Insert a new column into the table."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5713 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5714 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5715 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5716 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5717 (let* ((col (max 1 (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5718 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5719 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5720 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5721 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5722 (colpos col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5723 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5724 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5725 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5726 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5727 (org-table-goto-column col t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5728 (insert "| "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5729 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5730 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5731 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5732 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5733 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5734
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5735 (defun org-table-find-dataline ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5736 "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
5737 (if (and (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5738 (not (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5739 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5740 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5741 (end (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5742 (move-to-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5743 (while (and (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5744 (or (not (= (current-column) col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5745 (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5746 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5747 (move-to-column col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5748 (if (and (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5749 (not (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5750 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5751 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5752 "Please position cursor in a data line for column operations")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5753
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5754 (defun org-table-delete-column ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5755 "Delete a column into the table."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5756 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5757 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5758 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5759 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5760 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5761 (let* ((col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5762 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5763 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5764 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5765 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5766 (colpos col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5767 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5768 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5769 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5770 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5771 (org-table-goto-column col t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5772 (and (looking-at "|[^|\n]+|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5773 (replace-match "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5774 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5775 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5776 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5777 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5778 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5779
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5780 (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
5781 "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
5782 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5783 (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
5784 (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
5785 "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
5786 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5787 (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
5788
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5789 (defun org-table-move-column (&optional left)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5790 "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
5791 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5792 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5793 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5794 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5795 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5796 (let* ((col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5797 (col1 (if left (1- col) col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5798 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5799 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5800 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5801 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5802 (colpos (if left (1- col) (1+ col))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5803 (if (and left (= col 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5804 (error "Cannot move column further left"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5805 (if (and (not left) (looking-at "[^|\n]*|[^|\n]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5806 (error "Cannot move column further right"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5807 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5808 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5809 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5810 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5811 (org-table-goto-column col1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5812 (and (looking-at "|\\([^|\n]+\\)|\\([^|\n]+\\)|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5813 (replace-match "|\\2|\\1|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5814 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5815 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5816 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5817 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5818 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5819
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5820 (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
5821 "Move table row down."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5822 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5823 (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
5824 (defun org-table-move-row-up ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5825 "Move table row up."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5826 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5827 (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
5828
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5829 (defun org-table-move-row (&optional up)
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
5830 "Move the current table line down. With arg UP, move it up."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5831 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5832 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5833 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5834 (tonew (if up 0 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5835 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5836 (beginning-of-line tonew)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5837 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5838 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5839 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5840 (error "Cannot move row further.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5841 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5842 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5843 (setq pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5844 (setq txt (buffer-substring (point) (1+ (point-at-eol))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5845 (delete-region (point) (1+ (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5846 (beginning-of-line tonew)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5847 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5848 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5849 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5850
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5851 (defun org-table-insert-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5852 "Insert a new row above the current line into the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5853 With prefix ARG, insert below the current line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5854 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5855 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5856 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5857 (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5858 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5859 (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5860 (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5861 (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
5862 (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
5863 (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
5864 (insert-before-markers "\n"))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5865 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5866 (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
5867 (and org-table-may-need-update (org-table-align))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5868
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5869 (defun org-table-insert-hline (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5870 "Insert a horizontal-line below the current line into the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5871 With prefix ARG, insert above the current line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5872 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5873 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5874 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5875 (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5876 (col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5877 start)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5878 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5879 (setq line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5880 (mapcar (lambda (x) (if (member x '(?| ?+))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5881 (prog1 (if start ?+ ?|) (setq start t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5882 (if start ?- ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5883 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5884 (setq line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5885 (mapcar (lambda (x) (if (equal x ?|)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5886 (prog1 (if start ?+ ?|) (setq start t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5887 (if start ?- ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5888 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5889 (beginning-of-line (if arg 1 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5890 (apply 'insert line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5891 (if (equal (char-before (point)) ?+)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5892 (progn (backward-delete-char 1) (insert "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5893 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5894 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5895 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5896
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5897 (defun org-table-kill-row ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5898 "Delete the current row or horizontal line from the table."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5899 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5900 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5901 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5902 (let ((col (current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5903 (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5904 (if (not (org-at-table-p)) (beginning-of-line 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5905 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5906
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5907
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5908 (defun org-table-cut-region ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5909 "Copy region in table to the clipboard and blank all relevant fields."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5910 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5911 (org-table-copy-region 'cut))
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 (defun org-table-copy-region (&optional cut)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5914 "Copy rectangular region in table to clipboard.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5915 A special clipboard is used which can only be accessed
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5916 with `org-table-paste-rectangle'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5917 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5918 (unless (org-region-active-p) (error "No active region"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5919 (let* ((beg (region-beginning))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5920 (end (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5921 l01 c01 l02 c02 l1 c1 l2 c2 ic1 ic2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5922 region cols
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5923 (rpl (if cut " " nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5924 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5925 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5926 (setq l01 (count-lines (point-min) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5927 c01 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5928 (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5929 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5930 (setq l02 (count-lines (point-min) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5931 c02 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5932 (setq l1 (min l01 l02) l2 (max l01 l02)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5933 c1 (min c01 c02) c2 (max c01 c02))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5934 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5935 (while t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5936 (catch 'nextline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5937 (if (> l1 l2) (throw 'exit t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5938 (goto-line l1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5939 (if (org-at-table-hline-p) (throw 'nextline (setq l1 (1+ l1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5940 (setq cols nil ic1 c1 ic2 c2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5941 (while (< ic1 (1+ ic2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5942 (push (org-table-get-field ic1 rpl) cols)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5943 (setq ic1 (1+ ic1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5944 (push (nreverse cols) region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5945 (setq l1 (1+ l1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5946 (setq org-table-clip (nreverse region))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5947 (if cut (org-table-align))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5948
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5949 (defun org-table-paste-rectangle ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5950 "Paste a rectangular region into a table.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5951 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
5952 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
5953 the table is enlarged as needed. The process ignores horizontal separator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5954 lines."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5955 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5956 (unless (and org-table-clip (listp org-table-clip))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5957 (error "First cut/copy a region to paste!"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5958 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5959 (let* ((clip org-table-clip)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5960 (line (count-lines (point-min) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5961 (col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5962 (org-enable-table-editor t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5963 (org-table-automatic-realign nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5964 c cols field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5965 (while (setq cols (pop clip))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5966 (while (org-at-table-hline-p) (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5967 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5968 (progn (end-of-line 0) (org-table-next-field)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5969 (setq c col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5970 (while (setq field (pop cols))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5971 (org-table-goto-column c nil 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5972 (org-table-get-field nil field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5973 (setq c (1+ c)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5974 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5975 (goto-line line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5976 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5977 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5978
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5979 (defun org-table-convert ()
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
5980 "Convert from `org-mode' table to table.el and back.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5981 Obviously, this only works within limits. When an Org-mode table is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5982 converted to table.el, all horizontal separator lines get lost, because
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5983 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
5984 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
5985 do row or column spanning. Multiline cells will become multiple cells.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5986 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
5987 blindly applies a recipe that works for simple tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5988 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5989 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5990 (if (org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5991 ;; convert to Org-mode table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5992 (let ((beg (move-marker (make-marker) (org-table-begin t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5993 (end (move-marker (make-marker) (org-table-end t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5994 (table-unrecognize-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5995 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5996 (while (re-search-forward "^\\([ \t]*\\)\\+-.*\n" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5997 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5998 (goto-char beg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5999 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6000 ;; convert to table.el table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6001 (let ((beg (move-marker (make-marker) (org-table-begin)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6002 (end (move-marker (make-marker) (org-table-end))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6003 ;; first, get rid of all horizontal lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6004 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6005 (while (re-search-forward "^\\([ \t]*\\)|-.*\n" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6006 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6007 ;; insert a hline before first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6008 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6009 (org-table-insert-hline 'above)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6010 ;; insert a hline after each line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6011 (while (progn (beginning-of-line 2) (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6012 (org-table-insert-hline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6013 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6014 (setq end (move-marker end (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6015 ;; replace "+" at beginning and ending of hlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6016 (while (re-search-forward "^\\([ \t]*\\)|-" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6017 (replace-match "\\1+-"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6018 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6019 (while (re-search-forward "-|[ \t]*$" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6020 (replace-match "-+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6021 (goto-char beg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6022
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6023 (defun org-table-wrap-region (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6024 "Wrap several fields in a column like a paragraph.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6025 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
6026 lines, in order to keep the table compact.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6027
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6028 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
6029 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
6030 lines. Generally, this makes the table more compact. A prefix ARG may be
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6031 used to change the number of desired lines. For example, `C-2 \\[org-table-wrap]'
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6032 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
6033 lines, the remaining lines remain empty. A negative prefix argument reduces
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6034 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
6035 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
6036 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
6037 the table first.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6038
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6039 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
6040 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
6041 line down.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6042
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6043 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
6044 blank, and the content is appended to the field above."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6045 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6046 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6047 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6048 ;; There is a region: fill as a paragraph
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6049 (let ((beg (region-beginning))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6050 nlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6051 (org-table-cut-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6052 (if (> (length (car org-table-clip)) 1)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6053 (error "Region must be limited to single column"))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6054 (setq nlines (if arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6055 (if (< arg 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6056 (+ (length org-table-clip) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6057 arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6058 (length org-table-clip)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6059 (setq org-table-clip
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6060 (mapcar 'list (org-wrap (mapconcat 'car org-table-clip " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6061 nil nlines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6062 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6063 (org-table-paste-rectangle))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6064 ;; No region, split the current field at point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6065 (if arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6066 ;; combine with field above
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6067 (let ((s (org-table-blank-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6068 (col (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6069 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6070 (while (org-at-table-hline-p) (beginning-of-line 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6071 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6072 (skip-chars-forward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6073 (skip-chars-backward " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6074 (insert " " (org-trim s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6075 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6076 ;; split field
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6077 (when (looking-at "\\([^|]+\\)+|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6078 (let ((s (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6079 (replace-match " |")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6080 (goto-char (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6081 (org-table-next-row)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6082 (insert (org-trim s) " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6083 (org-table-align))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6084
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6085 (defun org-trim (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6086 "Remove whitespace at beginning and end of string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6087 (if (string-match "^[ \t]+" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6088 (if (string-match "[ \t]+$" s) (setq s (replace-match "" t t s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6089
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6090 (defun org-wrap (string &optional width lines)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6091 "Wrap string to either a number of lines, or a width in characters.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6092 If WIDTH is non-nil, the string is wrapped to that width, however many lines
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6093 that costs. If there is a word longer than WIDTH, the text is actually
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6094 wrapped to the length of that word.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6095 IF WIDTH is nil and LINES is non-nil, the string is forced into at most that
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6096 many lines, whatever width that takes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6097 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
6098 (let* ((words (org-split-string string "[ \t\n]+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6099 (maxword (apply 'max (mapcar 'length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6100 w ll)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6101 (cond (width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6102 (org-do-wrap words (max maxword width)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6103 (lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6104 (setq w maxword)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6105 (setq ll (org-do-wrap words maxword))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6106 (if (<= (length ll) lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6107 ll
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6108 (setq ll words)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6109 (while (> (length ll) lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6110 (setq w (1+ w))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6111 (setq ll (org-do-wrap words w)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6112 ll))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6113 (t (error "Cannot wrap this")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6114
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 (defun org-do-wrap (words width)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6117 "Create lines of maximum width WIDTH (in characters) from word list WORDS."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6118 (let (lines line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6119 (while words
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6120 (setq line (pop words))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6121 (while (and words (< (+ (length line) (length (car words))) width))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6122 (setq line (concat line " " (pop words))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6123 (setq lines (push line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6124 (nreverse lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6125
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6126 ;; FIXME: I think I can make this more efficient
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6127 (defun org-split-string (string &optional separators)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6128 "Splits STRING into substrings at SEPARATORS.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6129 No empty strings are returned if there are matches at the beginning
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6130 and end of string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6131 (let ((rexp (or separators "[ \f\t\n\r\v]+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6132 (start 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6133 notfirst
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6134 (list nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6135 (while (and (string-match rexp string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6136 (if (and notfirst
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6137 (= start (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6138 (< start (length string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6139 (1+ start) start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6140 (< (match-beginning 0) (length string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6141 (setq notfirst t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6142 (or (eq (match-beginning 0) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6143 (and (eq (match-beginning 0) (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6144 (eq (match-beginning 0) start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6145 (setq list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6146 (cons (substring string start (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6147 list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6148 (setq start (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6149 (or (eq start (length string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6150 (setq list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6151 (cons (substring string start)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6152 list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6153 (nreverse list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6154
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6155 (defun org-table-add-invisible-to-vertical-lines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6156 "Add an `invisible' property to vertical lines of current table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6157 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6158 (let* ((beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6159 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6160 (end1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6161 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6162 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6163 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6164 (setq end1 (point-at-eol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6165 (if (looking-at org-table-dataline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6166 (while (re-search-forward "|" end1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6167 (add-text-properties (1- (point)) (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6168 '(invisible org-table)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6169 (while (re-search-forward "[+|]" end1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6170 (add-text-properties (1- (point)) (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6171 '(invisible org-table))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6172 (beginning-of-line 2)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6173
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6174 (defun org-table-toggle-vline-visibility (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6175 "Toggle the visibility of table vertical lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6176 The effect is immediate and on all tables in the file.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6177 With prefix ARG, make lines invisible when ARG is positive, make lines
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6178 visible when ARG is not positive"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6179 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6180 (let ((action (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6181 ((and arg (> (prefix-numeric-value arg) 0)) 'on)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6182 ((and arg (< (prefix-numeric-value arg) 1)) 'off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6183 (t (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6184 'off
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6185 'on)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6186 (if (eq action 'off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6187 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6188 (org-remove-from-invisibility-spec '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6189 (org-table-map-tables 'org-table-align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6190 (message "Vertical table lines visible")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6191 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6192 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6193 (org-add-to-invisibility-spec '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6194 (org-table-map-tables 'org-table-align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6195 (message "Vertical table lines invisible"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6196 (redraw-frame (selected-frame))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6197
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6198 (defun org-table-map-tables (function)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6199 "Apply FUNCTION to the start of all tables in the buffer."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6200 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6201 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6202 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6203 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6204 (while (re-search-forward org-table-any-line-regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6205 (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6206 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6207 (if (looking-at org-table-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6208 (save-excursion (funcall function)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6209 (re-search-forward org-table-any-border-regexp nil 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6210
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6211 (defun org-table-sum ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6212 "Sum numbers in region of current table column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6213 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
6214 as kill to be inserted with \\[yank].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6215
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6216 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
6217 numbers in that rectangle will be summed. If there is no active
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6218 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
6219 column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6220
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6221 If at least one number looks like a time HH:MM or HH:MM:SS, all other
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6222 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
6223 numbers are added as such."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6224 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6225 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6226 (let (beg end col (timecnt 0) diff h m s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6227 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6228 (setq beg (region-beginning) end (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6229 (setq col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6230 (goto-char (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6231 (unless (re-search-forward "^[ \t]*|[^-]" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6232 (error "No table data"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6233 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6234 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6235 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6236 (goto-char (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6237 (unless (re-search-backward "^[ \t]*|[^-]" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6238 (error "No table data"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6239 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6240 (skip-chars-forward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6241 (setq end (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6242 (let* ((l1 (progn (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6243 (+ (if (bolp) 1 0) (count-lines (point-min) (point)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6244 (l2 (progn (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6245 (+ (if (bolp) 1 0) (count-lines (point-min) (point)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6246 (items (if (= l1 l2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6247 (split-string (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6248 (split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6249 (mapconcat 'identity (extract-rectangle beg end) " "))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6250 (numbers (delq nil (mapcar 'org-table-get-number-for-summing
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6251 items)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6252 (res (apply '+ numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6253 (sres (if (= timecnt 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6254 (format "%g" res)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6255 (setq diff (* 3600 res)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6256 h (floor (/ diff 3600)) diff (mod diff 3600)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6257 m (floor (/ diff 60)) diff (mod diff 60)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6258 s diff)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6259 (format "%d:%02d:%02d" h m s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6260 (kill-new sres)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6261 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6262 (format "Sum of %d items: %-20s (\\[yank] will insert result into buffer)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6263 (length numbers) sres)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6264
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6265 (defun org-table-get-number-for-summing (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6266 (let (n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6267 (if (string-match "^ *|? *" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6268 (setq s (replace-match "" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6269 (if (string-match " *|? *$" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6270 (setq s (replace-match "" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6271 (setq n (string-to-number s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6272 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6273 ((and (string-match "0" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6274 (string-match "\\`[-+ \t0.edED]+\\'" s)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6275 ((string-match "\\`[ \t]+\\'" s) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6276 ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?\\'" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6277 (let ((h (string-to-number (or (match-string 1 s) "0")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6278 (m (string-to-number (or (match-string 2 s) "0")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6279 (s (string-to-number (or (match-string 4 s) "0"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6280 (if (boundp 'timecnt) (setq timecnt (1+ timecnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6281 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6282 ((equal n 0) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6283 (t n))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6284
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6285 (defvar org-table-current-formula nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6286 (defvar org-table-formula-history nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6287 (defun org-table-get-formula (current)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6288 (if (and current (not (equal "" org-table-current-formula)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6289 org-table-current-formula
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6290 (setq org-table-current-formula
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6291 (read-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6292 "Formula [last]: " "" 'org-table-formula-history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6293 org-table-current-formula))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6294
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6295 (defun org-this-word ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6296 ;; Get the current word
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6297 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6298 (let ((beg (progn (skip-chars-backward "^ \t\n") (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6299 (end (progn (skip-chars-forward "^ \t\n") (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6300 (buffer-substring-no-properties beg end))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6301
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6302 (defun org-table-eval-formula (&optional ndown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6303 "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
6304
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6305 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
6306 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
6307 installed in order to use this function.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6308
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6309 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
6310 result of a formula. While nowhere near the computation options of a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6311 spreadsheet program, this is still very useful. Note that there is no
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6312 automatic updating of a calculated field, nor will the field remember the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6313 formula. The command needs to be applied again after changing input
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6314 fields.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6315
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6316 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
6317 minibuffer. Previously entered formulae are available through the history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6318 list, and the last used formula is the default, reachable by simply
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6319 pressing RET.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6320
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6321 The formula can be any algebraic expression understood by the calc package.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6322 Before evaluation, variable substitution takes place: \"$\" is replaced by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6323 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
6324 the current row. Values from a *different* row can *not* be referenced
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6325 here, so the command supports only horizontal computing. The formula can
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6326 contain an optional printf format specifier after a semicolon, to reformat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6327 the result.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6328
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6329 A few examples for formulae:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6330 $1+$2 Sum of first and second field
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6331 $1+$2;%.2f Same, and format result to two digits after dec.point
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6332 exp($2)+exp($1) Math functions can be used
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6333 $;%.1f Reformat current cell to 1 digit after dec.point
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6334 ($3-32)*5/9 degrees F -> C conversion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6335
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6336 When called with a raw \\[universal-argument] prefix, the formula is applied to the current
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6337 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
6338 horizontal line or the end of the table. When the command is called with a
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6339 numeric prefix argument (like M-3 or C-7 or \\[universal-argument] 24), the formula is applied
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6340 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
6341 separator line)."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6342 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6343 (setq ndown (if (equal ndown '(4)) 10000 (prefix-numeric-value ndown)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6344 (require 'calc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6345 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6346 (let* (fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6347 (org-table-automatic-realign nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6348 (down (> ndown 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6349 (formula (org-table-get-formula nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6350 (n0 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6351 n form fmt x ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6352 (if (string-match ";" formula)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6353 (let ((tmp (org-split-string formula ";")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6354 (setq formula (car tmp) fmt (nth 1 tmp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6355 (while (> ndown 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6356 (setq fields (org-split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6357 (concat " " (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6358 (point-at-bol) (point-at-eol))) "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6359 (setq ndown (1- ndown))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6360 (setq form (copy-sequence formula))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6361 (while (string-match "\\$\\([0-9]+\\)?" form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6362 (setq n (if (match-beginning 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6363 (string-to-int (match-string 1 form))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6364 n0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6365 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
6366 (unless x (error "Invalid field specifier \"%s\""
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6367 (match-string 0 form)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6368 (if (equal (string-to-number x) 0) (setq x "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6369 (setq form (replace-match x t t form)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6370 (setq ev (calc-eval (list form) 'num))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6371 (if (listp ev)
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59596
diff changeset
6372 (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
6373 (org-table-blank-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6374 (if fmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6375 (insert (format fmt (string-to-number ev)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6376 (insert ev))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6377 (if (and down (> ndown 0) (looking-at ".*\n[ \t]*|[^-]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6378 (call-interactively 'org-return)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6379 (setq ndown 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6380 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6381
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6382 ;;; The orgtbl minor mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6383
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6384 ;; 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
6385 ;; 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
6386
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6387 ;; 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
6388 ;; 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
6389 ;; 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
6390 ;; 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
6391 ;; 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
6392 ;; 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
6393 ;; 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
6394 ;; 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
6395 ;; 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
6396 ;; 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
6397 ;; 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
6398
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6399 ;; 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
6400 ;; 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
6401 ;; 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
6402
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6403 ;; 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
6404 ;; 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
6405 ;; 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
6406 ;; 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
6407 ;; 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
6408 ;; modified self-insert.
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 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6411 "Non-nil means, use the optimized table editor version for `orgtbl-mode'.
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6412 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
6413 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
6414 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
6415 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
6416 restored.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6417
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6418 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
6419 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
6420 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
6421 :group 'org-table
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6422 :type 'boolean)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6423
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6424 (defvar orgtbl-mode nil
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6425 "Variable controlling `orgtbl-mode', a minor mode enabling the `org-mode'
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6426 table editor in arbitrary modes.")
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6427 (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
6428
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6429 (defvar orgtbl-mode-map (make-sparse-keymap)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6430 "Keymap for `orgtbl-mode'.")
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6431
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6432 ;;;###autoload
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6433 (defun turn-on-orgtbl ()
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6434 "Unconditionally turn on `orgtbl-mode'."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6435 (orgtbl-mode 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6436
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6437 ;;;###autoload
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6438 (defun orgtbl-mode (&optional arg)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6439 "The `org-mode' table editor as a minor mode for use in other modes."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6440 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6441 (setq orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6442 (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
6443 (if orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6444 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6445 (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
6446 (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
6447 (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
6448 nil 'local)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6449 (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
6450 auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6451 (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
6452 (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
6453 (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
6454 "[ \t]*|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6455 (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
6456 (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
6457 (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
6458 (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
6459 (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
6460 (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
6461
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6462 ;; 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
6463 (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
6464 (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
6465 (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
6466
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6467 (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
6468 "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
6469 (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
6470 (list 'if
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6471 '(org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6472 (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
6473 (list 'let '(orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6474 (list 'call-interactively
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6475 (append '(or)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6476 (mapcar (lambda (k)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6477 (list 'key-binding k))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6478 keys)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6479 '('orgtbl-error)))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6480
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6481 (defun orgtbl-error ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6482 "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
6483 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6484 (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
6485
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6486 ;; 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
6487 (let ((bindings
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6488 '(([(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
6489 ([(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
6490 ([(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
6491 ([(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
6492 ([(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
6493 ([(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
6494 ([(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
6495 ([(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
6496 ("\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
6497 ("\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
6498 ("\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
6499 ("\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
6500 ([(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
6501 ("\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
6502 ([(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
6503 ([(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
6504 ([(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
6505 ("\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
6506 ("\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
6507 ("\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
6508 ("\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
6509 ("\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
6510 ("\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
6511 elt key fun cmd)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6512 (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
6513 (setq key (car elt)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6514 fun (nth 1 elt)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6515 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
6516 (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
6517
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6518 ;; 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
6519 ;(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
6520 ; (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
6521 ;(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
6522 ; (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
6523 ;(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
6524 ; (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
6525 ;(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
6526 ; (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
6527
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6528 (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
6529 (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
6530 (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
6531 (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
6532 (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
6533 (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
6534 (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
6535 (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
6536
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6537 (when orgtbl-optimized
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6538 ;; 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
6539 ;; some standard editing functions
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6540 (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
6541 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
6542 (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
6543 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
6544 (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
6545 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
6546 (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
6547
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6548 (defun orgtbl-tab ()
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6549 "Justification and field motion for `orgtbl-mode'."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6550 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6551 (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
6552 (org-table-next-field))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6553
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6554 (defun orgtbl-ret ()
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6555 "Justification and field motion for `orgtbl-mode'."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6556 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6557 (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
6558 (org-table-next-row))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6559
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6560 (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
6561 "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
6562 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
6563 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
6564 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6565 (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
6566 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6567 (looking-at "[^|\n]* +|"))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6568 (let (org-table-may-need-update)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6569 (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
6570 (delete-backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6571 (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
6572 (self-insert-command N))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6573 (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
6574 (let (orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6575 (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
6576
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6577 (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
6578 "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
6579 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
6580 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
6581 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
6582 reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6583 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6584 (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
6585 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6586 (looking-at ".*?|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6587 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6588 (backward-delete-char N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6589 (skip-chars-forward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6590 (insert " ")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6591 (goto-char (1- pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6592 (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
6593 (delete-backward-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6594
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6595 (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
6596 "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
6597 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
6598 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
6599 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
6600 a reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6601 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6602 (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
6603 (eq N 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6604 (if (looking-at ".*?|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6605 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6606 (replace-match (concat
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6607 (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
6608 " |"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6609 (goto-char pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6610 (delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6611
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6612 (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
6613 '("Tbl"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6614 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6615 ["Next Field" org-cycle :active (org-at-table-p) :keys "TAB"]
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6616 ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6617 ["Next Row" org-return :active (org-at-table-p) :keys "RET"]
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6618 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6619 ["Blank Field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6620 ["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
6621 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
6622 "--"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6623 ("Column"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6624 ["Move Column Left" org-metaleft :active (org-at-table-p) :keys "M-<left>"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6625 ["Move Column Right" org-metaright :active (org-at-table-p) :keys "M-<right>"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6626 ["Delete Column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6627 ["Insert Column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"])
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6628 ("Row"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6629 ["Move Row Up" org-metaup :active (org-at-table-p) :keys "M-<up>"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6630 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6631 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6632 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6633 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6634 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6635 ("Rectangle"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6636 ["Copy Rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6637 ["Cut Rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6638 ["Paste Rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6639 ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"])
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6640 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6641 ["Which Column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6642 ["Sum Column/Rectangle" org-table-sum
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6643 :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6644 ["Eval Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6645 ))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6646
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6647 ;;; Exporting
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6648
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6649 (defconst org-level-max 20)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6650
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6651 (defun org-export-find-first-heading-line (list)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6652 "Remove all lines from LIST which are before the first headline."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6653 (let ((orig-list list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6654 (re (concat "^" outline-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6655 (while (and list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6656 (not (string-match re (car list))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6657 (pop list))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6658 (or list orig-list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6659
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6660 (defun org-skip-comments (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6661 "Skip lines starting with \"#\" and subtrees starting with COMMENT."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6662 (let ((re1 (concat "^\\(\\*+\\)[ \t]+" org-comment-string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6663 (re2 "^\\(\\*+\\)[ \t\n\r]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6664 rtn line level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6665 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6666 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6667 ((and (string-match re1 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6668 (setq level (- (match-end 1) (match-beginning 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6669 ;; Beginning of a COMMENT subtree. Skip it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6670 (while (and (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6671 (or (not (string-match re2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6672 (> (- (match-end 1) (match-beginning 1)) level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6673 (setq lines (cons line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6674 ((string-match "^#" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6675 ;; an ordinary comment line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6676 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6677 (t (setq rtn (cons line rtn)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6678 (nreverse rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6679
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6680 ;; ASCII
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6681
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6682 (defconst org-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6683 "Characters for underlining headings in ASCII export.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6684
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6685 (defconst org-html-entities
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6686 '(("nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6687 ("iexcl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6688 ("cent")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6689 ("pound")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6690 ("curren")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6691 ("yen")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6692 ("brvbar")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6693 ("sect")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6694 ("uml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6695 ("copy")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6696 ("ordf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6697 ("laquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6698 ("not")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6699 ("shy")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6700 ("reg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6701 ("macr")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6702 ("deg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6703 ("plusmn")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6704 ("sup2")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6705 ("sup3")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6706 ("acute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6707 ("micro")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6708 ("para")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6709 ("middot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6710 ("odot"."o")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6711 ("star"."*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6712 ("cedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6713 ("sup1")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6714 ("ordm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6715 ("raquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6716 ("frac14")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6717 ("frac12")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6718 ("frac34")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6719 ("iquest")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6720 ("Agrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6721 ("Aacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6722 ("Acirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6723 ("Atilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6724 ("Auml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6725 ("Aring") ("AA"."&Aring;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6726 ("AElig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6727 ("Ccedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6728 ("Egrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6729 ("Eacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6730 ("Ecirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6731 ("Euml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6732 ("Igrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6733 ("Iacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6734 ("Icirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6735 ("Iuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6736 ("ETH")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6737 ("Ntilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6738 ("Ograve")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6739 ("Oacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6740 ("Ocirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6741 ("Otilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6742 ("Ouml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6743 ("times")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6744 ("Oslash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6745 ("Ugrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6746 ("Uacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6747 ("Ucirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6748 ("Uuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6749 ("Yacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6750 ("THORN")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6751 ("szlig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6752 ("agrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6753 ("aacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6754 ("acirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6755 ("atilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6756 ("auml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6757 ("aring")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6758 ("aelig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6759 ("ccedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6760 ("egrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6761 ("eacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6762 ("ecirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6763 ("euml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6764 ("igrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6765 ("iacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6766 ("icirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6767 ("iuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6768 ("eth")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6769 ("ntilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6770 ("ograve")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6771 ("oacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6772 ("ocirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6773 ("otilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6774 ("ouml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6775 ("divide")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6776 ("oslash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6777 ("ugrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6778 ("uacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6779 ("ucirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6780 ("uuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6781 ("yacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6782 ("thorn")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6783 ("yuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6784 ("fnof")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6785 ("Alpha")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6786 ("Beta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6787 ("Gamma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6788 ("Delta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6789 ("Epsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6790 ("Zeta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6791 ("Eta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6792 ("Theta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6793 ("Iota")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6794 ("Kappa")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6795 ("Lambda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6796 ("Mu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6797 ("Nu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6798 ("Xi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6799 ("Omicron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6800 ("Pi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6801 ("Rho")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6802 ("Sigma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6803 ("Tau")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6804 ("Upsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6805 ("Phi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6806 ("Chi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6807 ("Psi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6808 ("Omega")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6809 ("alpha")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6810 ("beta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6811 ("gamma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6812 ("delta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6813 ("epsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6814 ("varepsilon"."&epsilon;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6815 ("zeta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6816 ("eta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6817 ("theta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6818 ("iota")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6819 ("kappa")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6820 ("lambda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6821 ("mu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6822 ("nu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6823 ("xi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6824 ("omicron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6825 ("pi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6826 ("rho")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6827 ("sigmaf") ("varsigma"."&sigmaf;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6828 ("sigma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6829 ("tau")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6830 ("upsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6831 ("phi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6832 ("chi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6833 ("psi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6834 ("omega")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6835 ("thetasym") ("vartheta"."&thetasym;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6836 ("upsih")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6837 ("piv")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6838 ("bull") ("bullet"."&bull;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6839 ("hellip") ("dots"."&hellip;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6840 ("prime")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6841 ("Prime")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6842 ("oline")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6843 ("frasl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6844 ("weierp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6845 ("image")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6846 ("real")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6847 ("trade")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6848 ("alefsym")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6849 ("larr") ("leftarrow"."&larr;") ("gets"."&larr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6850 ("uarr") ("uparrow"."&uarr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6851 ("rarr") ("to"."&rarr;") ("rightarrow"."&rarr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6852 ("darr")("downarrow"."&darr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6853 ("harr") ("leftrightarrow"."&harr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6854 ("crarr") ("hookleftarrow"."&crarr;") ; has round hook, not quite CR
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6855 ("lArr") ("Leftarrow"."&lArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6856 ("uArr") ("Uparrow"."&uArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6857 ("rArr") ("Rightarrow"."&rArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6858 ("dArr") ("Downarrow"."&dArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6859 ("hArr") ("Leftrightarrow"."&hArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6860 ("forall")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6861 ("part") ("partial"."&part;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6862 ("exist") ("exists"."&exist;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6863 ("empty") ("emptyset"."&empty;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6864 ("nabla")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6865 ("isin") ("in"."&isin;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6866 ("notin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6867 ("ni")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6868 ("prod")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6869 ("sum")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6870 ("minus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6871 ("lowast") ("ast"."&lowast;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6872 ("radic")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6873 ("prop") ("proptp"."&prop;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6874 ("infin") ("infty"."&infin;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6875 ("ang") ("angle"."&ang;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6876 ("and") ("vee"."&and;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6877 ("or") ("wedge"."&or;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6878 ("cap")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6879 ("cup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6880 ("int")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6881 ("there4")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6882 ("sim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6883 ("cong") ("simeq"."&cong;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6884 ("asymp")("approx"."&asymp;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6885 ("ne") ("neq"."&ne;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6886 ("equiv")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6887 ("le")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6888 ("ge")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6889 ("sub") ("subset"."&sub;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6890 ("sup") ("supset"."&sup;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6891 ("nsub")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6892 ("sube")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6893 ("supe")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6894 ("oplus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6895 ("otimes")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6896 ("perp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6897 ("sdot") ("cdot"."&sdot;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6898 ("lceil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6899 ("rceil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6900 ("lfloor")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6901 ("rfloor")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6902 ("lang")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6903 ("rang")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6904 ("loz") ("Diamond"."&loz;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6905 ("spades") ("spadesuit"."&spades;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6906 ("clubs") ("clubsuit"."&clubs;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6907 ("hearts") ("diamondsuit"."&hearts;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6908 ("diams") ("diamondsuit"."&diams;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6909 ("quot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6910 ("amp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6911 ("lt")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6912 ("gt")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6913 ("OElig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6914 ("oelig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6915 ("Scaron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6916 ("scaron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6917 ("Yuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6918 ("circ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6919 ("tilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6920 ("ensp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6921 ("emsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6922 ("thinsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6923 ("zwnj")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6924 ("zwj")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6925 ("lrm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6926 ("rlm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6927 ("ndash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6928 ("mdash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6929 ("lsquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6930 ("rsquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6931 ("sbquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6932 ("ldquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6933 ("rdquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6934 ("bdquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6935 ("dagger")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6936 ("Dagger")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6937 ("permil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6938 ("lsaquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6939 ("rsaquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6940 ("euro")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6941
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6942 ("arccos"."arccos")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6943 ("arcsin"."arcsin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6944 ("arctan"."arctan")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6945 ("arg"."arg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6946 ("cos"."cos")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6947 ("cosh"."cosh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6948 ("cot"."cot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6949 ("coth"."coth")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6950 ("csc"."csc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6951 ("deg"."deg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6952 ("det"."det")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6953 ("dim"."dim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6954 ("exp"."exp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6955 ("gcd"."gcd")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6956 ("hom"."hom")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6957 ("inf"."inf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6958 ("ker"."ker")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6959 ("lg"."lg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6960 ("lim"."lim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6961 ("liminf"."liminf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6962 ("limsup"."limsup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6963 ("ln"."ln")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6964 ("log"."log")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6965 ("max"."max")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6966 ("min"."min")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6967 ("Pr"."Pr")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6968 ("sec"."sec")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6969 ("sin"."sin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6970 ("sinh"."sinh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6971 ("sup"."sup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6972 ("tan"."tan")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6973 ("tanh"."tanh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6974 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6975 "Entities for TeX->HTML translation.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6976 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
6977 \"&ent;\". An entry can also be a dotted pair like (\"ent\".\"&other;\").
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6978 In that case, \"\\ent\" will be translated to \"&other;\".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6979 The list contains HTML entities for Latin-1, Greek and other symbols.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6980 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
6981 translations.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6982
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6983 (defvar org-last-level nil) ; dynamically scoped variable
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
6984
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6985 (defun org-export-as-ascii (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6986 "Export the outline as a pretty ASCII file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6987 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6988 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6989 underlined headlines. The default is 3."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6990 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6991 (setq-default org-todo-line-regexp org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6992 (let* ((region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6993 (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6994 (if (org-region-active-p) (region-beginning) (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6995 (if (org-region-active-p) (region-end) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6996 (lines (org-export-find-first-heading-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6997 (org-skip-comments (org-split-string region "[\r\n]"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6998 (org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6999 (level 0) line txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7000 (umax nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7001 (case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7002 (filename (concat (file-name-sans-extension (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7003 ".txt"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7004 (buffer (find-file-noselect filename))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7005 (levels-open (make-vector org-level-max nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7006 (date (format-time-string "%Y/%m/%d" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7007 (time (format-time-string "%X" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7008 (author user-full-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7009 (title (buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7010 (options nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7011 (email user-mail-address)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7012 (language org-export-default-language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7013 (text nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7014 (todo nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7015 (lang-words nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7016
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7017 (setq org-last-level 1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7018 (org-init-section-numbers)
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 (find-file-noselect filename)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7021
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7022 ;; Search for the export key lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7023 (org-parse-key-lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7024
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7025 (setq lang-words (or (assoc language org-export-language-setup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7026 (assoc "en" org-export-language-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7027 (if org-export-ascii-show-new-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7028 (switch-to-buffer-other-window buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7029 (set-buffer buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7030 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7031 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7032 (if options (org-parse-export-options options))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7033 (setq umax (if arg (prefix-numeric-value arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7034 org-export-headline-levels))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7035
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7036 ;; File header
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7037 (if title (org-insert-centered title ?=))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7038 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7039 (if (or author email)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7040 (insert (concat (nth 1 lang-words) ": " (or author "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7041 (if email (concat " <" email ">") "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7042 "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7043 (if (and date time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7044 (insert (concat (nth 2 lang-words) ": " date " " time "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7045 (if text (insert (concat (org-html-expand-for-ascii text) "\n\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7046
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7047 (insert "\n\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7048
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7049 (if org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7050 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7051 (insert (nth 3 lang-words) "\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7052 (make-string (length (nth 3 lang-words)) ?=) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7053 (mapcar '(lambda (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7054 (if (string-match org-todo-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7055 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7056 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7057 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7058 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7059 txt (match-string 3 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7060 todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7061 (or (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7062 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7063 org-done-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7064 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7065 (and (= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7066 (org-search-todo-below
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7067 line lines level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7068 (setq txt (org-html-expand-for-ascii txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7069
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7070 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7071 (setq txt (concat (org-section-number level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7072 " " txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7073 (if (<= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7074 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7075 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7076 (make-string (* (1- level) 4) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7077 (format (if todo "%s (*)\n" "%s\n") txt))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7078 (setq org-last-level level))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7079 ))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7080 lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7081
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7082 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7083 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7084 ;; Remove the quoted HTML tags.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7085 (setq line (org-html-expand-for-ascii line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7086 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7087 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7088 ;; a Headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7089 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7090 txt (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7091 (org-ascii-level-start level txt umax))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7092 (t (insert line "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7093 (normal-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7094 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7095 (goto-char (point-min))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7096
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7097 (defun org-search-todo-below (line lines level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7098 "Search the subtree below LINE for any TODO entries."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7099 (let ((rest (cdr (memq line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7100 (re org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7101 line lv todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7102 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7103 (while (setq line (pop rest))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7104 (if (string-match re line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7105 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7106 (setq lv (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7107 todo (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7108 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7109 org-done-string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7110 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7111 (if (<= lv level) (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7112 (if todo (throw 'exit t))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7113
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7114 ;; FIXME: Try to handle <b> and <i> as faces via text properties.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7115 ;; FIXME: Can I implement *bold*,/italic/ and _underline_ for ASCII export?
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7116 (defun org-html-expand-for-ascii (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7117 "Handle quoted HTML for ASCII export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7118 (if org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7119 (while (string-match "@<[^<>\n]*>" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7120 ;; We just remove the tags for now.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7121 (setq line (replace-match "" nil nil line))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7122 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7123
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7124 (defun org-insert-centered (s &optional underline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7125 "Insert the string S centered and underline it with character UNDERLINE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7126 (let ((ind (max (/ (- 80 (length s)) 2) 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7127 (insert (make-string ind ?\ ) s "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7128 (if underline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7129 (insert (make-string ind ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7130 (make-string (length s) underline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7131 "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7132
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7133 (defun org-ascii-level-start (level title umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7134 "Insert a new level in ASCII export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7135 (let (char)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7136 (if (> level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7137 (insert (make-string (* 2 (- level umax 1)) ?\ ) "* " title "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7138 (if (or (not (equal (char-before) ?\n))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7139 (not (equal (char-before (1- (point))) ?\n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7140 (insert "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7141 (setq char (nth (- umax level) (reverse org-ascii-underline)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7142 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7143 (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
7144 (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
7145
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7146 (defun org-export-copy-visible ()
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7147 "Copy the visible part of the buffer to another buffer, for printing.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7148 Also removes the first line of the buffer if it specifies a mode,
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7149 and all options lines."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7150 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7151 (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
7152 ".txt"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7153 (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
7154 (ore (concat
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7155 (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
7156 '("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
7157 "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
7158 (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
7159 s e)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7160 (with-current-buffer buffer
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7161 (erase-buffer)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7162 (text-mode))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7163 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7164 (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
7165 (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
7166 (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
7167 (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
7168 (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
7169 (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
7170 (newline)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7171 (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
7172 (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
7173 (replace-match ""))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7174 (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
7175 (replace-match ""))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7176 (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
7177
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7178 (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
7179 (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
7180 (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
7181 (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
7182 (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
7183 s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7184 (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
7185 (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7186 (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
7187 (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
7188 (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
7189 (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
7190 (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
7191 s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7192 (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
7193 (point)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7194
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7195 ;; HTML
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7196
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7197 (defun org-get-current-options ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7198 "Return a string with current options as keyword options.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7199 Does include HTML export options as well as TODO and CATEGORY stuff."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7200 (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7201 "#+TITLE: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7202 #+AUTHOR: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7203 #+EMAIL: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7204 #+LANGUAGE: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7205 #+TEXT: Some descriptive text to be emitted. Several lines OK.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7206 #+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
7207 #+CATEGORY: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7208 #+SEQ_TODO: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7209 #+TYP_TODO: %s
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7210 #+STARTUP: %s %s
58792
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 (buffer-name) (user-full-name) user-mail-address org-export-default-language
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7213 org-export-headline-levels
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7214 org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7215 org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7216 org-export-preserve-breaks
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7217 org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7218 org-export-with-fixed-width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7219 org-export-with-tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7220 org-export-with-sub-superscripts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7221 org-export-with-emphasize
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7222 org-export-with-TeX-macros
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7223 (file-name-nondirectory (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7224 (if (equal org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7225 (mapconcat 'identity org-todo-keywords " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7226 "TODO FEEDBACK VERIFY DONE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7227 (if (equal org-todo-interpretation 'type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7228 (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
7229 "Me Jason Marie DONE")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7230 (cdr (assoc org-startup-folded
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7231 '((nil . "nofold")(t . "fold")(content . "content"))))
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7232 (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
7233 ))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7234
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7235 (defun org-insert-export-options-template ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7236 "Insert into the buffer a template with information for exporting."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7237 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7238 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7239 (let ((s (org-get-current-options)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7240 (and (string-match "#\\+CATEGORY" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7241 (setq s (substring s 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7242 (insert s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7243
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7244 (defun org-toggle-fixed-width-section (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7245 "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
7246 If there is no active region, only acts on the current line.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7247 If the first non-white character in the first line of the region is a
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7248 vertical bar \"|\", then the command removes the bar from all lines in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7249 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
7250 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
7251
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7252 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
7253 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7254 (let* ((cc 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7255 (regionp (org-region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7256 (beg (if regionp (region-beginning) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7257 (end (if regionp (region-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7258 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7259 (re "[ \t]*\\(:\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7260 off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7261 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7262 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7263 (setq cc (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7264 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7265 (setq off (looking-at re))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7266 (while (> nlines 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7267 (setq nlines (1- nlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7268 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7269 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7270 (arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7271 (move-to-column cc t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7272 (insert ":\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7273 (forward-line -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7274 ((and off (looking-at re))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7275 (replace-match "" t t nil 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7276 ((not off) (move-to-column cc t) (insert ":")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7277 (forward-line 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7278
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7279 (defun org-export-as-html-and-open (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7280 "Export the outline as HTML and immediately open it with a browser.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7281 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7282 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7283 headlines. The default is 3. Lower levels will become bulleted lists."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7284 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7285 (org-export-as-html arg 'hidden)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7286 (org-open-file (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7287
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7288 (defun org-export-as-html-batch ()
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7289 "Call `org-export-as-html', may be used in batch processing as
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7290 emacs --batch
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7291 --load=$HOME/lib/emacs/org.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7292 --eval \"(setq org-export-headline-levels 2)\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7293 --visit=MyFile --funcall org-export-as-html-batch"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7294 (org-export-as-html org-export-headline-levels 'hidden))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7295
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7296 (defun org-export-as-html (arg &optional hidden)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7297 "Export the outline as a pretty HTML file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7298 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7299 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7300 headlines. The default is 3. Lower levels will become bulleted lists."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7301 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7302 (setq-default org-todo-line-regexp org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7303 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7304 (setq-default org-done-string org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7305 (let* ((region-p (org-region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7306 (region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7307 (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7308 (if region-p (region-beginning) (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7309 (if region-p (region-end) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7310 (all_lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7311 (org-skip-comments (org-split-string region "[\r\n]")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7312 (lines (org-export-find-first-heading-line all_lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7313 (level 0) (line "") (origline "") txt todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7314 (umax nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7315 (filename (concat (file-name-sans-extension (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7316 ".html"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7317 (buffer (find-file-noselect filename))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7318 (levels-open (make-vector org-level-max nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7319 (date (format-time-string "%Y/%m/%d" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7320 (time (format-time-string "%X" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7321 (author user-full-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7322 (title (buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7323 (options nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7324 (email user-mail-address)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7325 (language org-export-default-language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7326 (text nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7327 (lang-words nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7328 (head-count 0) cnt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7329 table-open type
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7330 table-buffer table-orig-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7331 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7332 (message "Exporting...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7333
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7334 (setq org-last-level 1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7335 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7336
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7337 ;; Search for the export key lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7338 (org-parse-key-lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7339 (setq lang-words (or (assoc language org-export-language-setup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7340 (assoc "en" org-export-language-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7341
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7342 ;; Switch to the output buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7343 (if (or hidden (not org-export-html-show-new-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7344 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7345 (switch-to-buffer-other-window buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7346 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7347 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7348 (let ((case-fold-search nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7349 (if options (org-parse-export-options options))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7350 (setq umax (if arg (prefix-numeric-value arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7351 org-export-headline-levels))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7352
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7353 ;; File header
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7354 (insert (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7355 "<html lang=\"%s\"><head>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7356 <title>%s</title>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7357 <meta http-equiv=\"Content-Type\" content=\"text/html\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7358 <meta name=generator content=\"Org-mode\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7359 <meta name=generated content=\"%s %s\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7360 <meta name=author content=\"%s\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7361 </head><body>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7362 "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7363 language (org-html-expand title) date time author))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7364 (if title (insert (concat "<H1 align=\"center\">"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7365 (org-html-expand title) "</H1>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7366 (if author (insert (concat (nth 1 lang-words) ": " author "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7367 (if email (insert (concat "<a href=\"mailto:" email "\">&lt;"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7368 email "&gt;</a>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7369 (if (or author email) (insert "<br>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7370 (if (and date time) (insert (concat (nth 2 lang-words) ": "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7371 date " " time "<br>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7372 (if text (insert (concat "<p>\n" (org-html-expand text))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7373 (if org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7374 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7375 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7376 (insert "<ul>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7377 (mapcar '(lambda (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7378 (if (string-match org-todo-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7379 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7380 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7381 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7382 txt (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7383 (org-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7384 (match-string 3 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7385 todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7386 (or (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7387 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7388 org-done-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7389 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7390 (and (= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7391 (org-search-todo-below
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7392 line lines level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7393 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7394 (setq txt (concat (org-section-number level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7395 " " txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7396 (if (<= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7397 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7398 (setq head-count (+ head-count 1))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7399 (if (> level org-last-level)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7400 (progn
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7401 (setq cnt (- level org-last-level))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7402 (while (>= (setq cnt (1- cnt)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7403 (insert "<ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7404 (insert "\n")))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7405 (if (< level org-last-level)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7406 (progn
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7407 (setq cnt (- org-last-level level))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7408 (while (>= (setq cnt (1- cnt)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7409 (insert "</ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7410 (insert "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7411 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7412 (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7413 (if todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7414 "<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
7415 "<li><a href=\"#sec-%d\">%s</a></li>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7416 head-count txt))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7417 (setq org-last-level level))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7418 ))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7419 lines)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7420 (while (> org-last-level 0)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7421 (setq org-last-level (1- org-last-level))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7422 (insert "</ul>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7423 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7424 (setq head-count 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7425 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7426
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7427 (while (setq line (pop lines) origline line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7428 ;; replace "<" and ">" by "&lt;" and "&gt;"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7429 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7430 (setq line (org-html-expand line))
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 ;; Verbatim lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7433 (if (and org-export-with-fixed-width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7434 (string-match "^[ \t]*:\\(.*\\)" line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7435 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7436 (let ((l (match-string 1 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7437 (while (string-match " " l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7438 (setq l (replace-match "&nbsp;" t t l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7439 (insert "\n<span style='font-family:Courier'>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7440 l "</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7441 (if (and lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7442 (not (string-match "^[ \t]+\\(:.*\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7443 (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7444 "<br>\n" "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7445
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7446 (when (string-match org-link-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7447 (setq type (match-string 1 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7448 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7449 ((member type '("http" "https" "ftp" "mailto" "news"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7450 ;; standard URL
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7451 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7452 "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7453 nil nil line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7454 ((string= type "file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7455 ;; FILE link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7456
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7457 (let* ((filename (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7458 (file-is-image-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7459 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7460 (string-match (org-image-file-name-regexp) filename))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7461 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7462 (if (and org-export-html-inline-images
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7463 file-is-image-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7464 "<img src=\"\\2\"/>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7465 "<a href=\"\\2\">\\1:\\2</a>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7466 nil nil line))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7467
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7468 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7469 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7470 "<i>&lt;\\1:\\2&gt;</i>" nil nil line)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7471
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7472 ;; TODO items
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7473 (if (and (string-match org-todo-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7474 (match-beginning 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7475 (if (equal (match-string 2 line) org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7476 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7477 "<span style='color:green'>\\2</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7478 nil nil line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7479 (setq line (replace-match "<span style='color:red'>\\2</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7480 nil nil line 2))))
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 ;; DEADLINES
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7483 (if (string-match org-deadline-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7484 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7485 (if (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7486 (string-match "<a href"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7487 (substring line 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7488 nil ; Don't do the replacement - it is inside a link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7489 (setq line (replace-match "<span style='color:red'>\\&</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7490 nil nil line 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7491
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7492 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7493 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7494 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7495 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7496 txt (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7497 (if (<= level umax) (setq head-count (+ head-count 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7498 (org-html-level-start level txt umax
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7499 (and org-export-with-toc (<= level umax))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7500 head-count))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7501
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7502 ((and org-export-with-tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7503 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7504 (if (not table-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7505 ;; New table starts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7506 (setq table-open t table-buffer nil table-orig-buffer nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7507 ;; Accumulate lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7508 (setq table-buffer (cons line table-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7509 table-orig-buffer (cons origline table-orig-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7510 (when (or (not lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7511 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7512 (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7513 (setq table-open nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7514 table-buffer (nreverse table-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7515 table-orig-buffer (nreverse table-orig-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7516 (insert (org-format-table-html table-buffer table-orig-buffer))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7517 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7518 ;; Normal lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7519 ;; Lines starting with "-", and empty lines make new paragraph.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7520 (if (string-match "^ *-\\|^[ \t]*$" line) (insert "<p>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7521 (insert line (if org-export-preserve-breaks "<br>\n" "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7522 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7523 (if org-export-html-with-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7524 (insert org-export-html-html-helper-timestamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7525 (insert "</body>\n</html>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7526 (normal-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7527 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7528 (goto-char (point-min)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7529
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7530 (defun org-format-table-html (lines olines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7531 "Find out which HTML converter to use and return the HTML code."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7532 (if (string-match "^[ \t]*|" (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7533 ;; A normal org table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7534 (org-format-org-table-html lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7535 ;; Table made by table.el - test for spanning
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7536 (let* ((hlines (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7537 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7538 (if (string-match "^[ \t]*\\+-" x) x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7539 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7540 lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7541 (first (car hlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7542 (ll (and (string-match "\\S-+" first)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7543 (match-string 0 first)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7544 (re (concat "^[ \t]*" (regexp-quote ll)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7545 (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7546 hlines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7547 (if (and (not spanning)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7548 (not org-export-prefer-native-exporter-for-tables))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7549 ;; We can use my own converter with HTML conversions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7550 (org-format-table-table-html lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7551 ;; 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
7552 (org-format-table-table-html-using-table-generate-source olines)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7553
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7554 (defun org-format-org-table-html (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7555 "Format a table into html."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7556 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7557 (setq lines (nreverse lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7558 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7559 (setq lines (nreverse lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7560 (let ((head (and org-export-highlight-first-table-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7561 (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7562 (lambda (x) (string-match "^[ \t]*|-" x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7563 lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7564 lastline line fields html empty)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7565 (setq html (concat org-export-html-table-tag "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7566 (while (setq lastline line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7567 line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7568 (setq empty "&nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7569 (catch 'next-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7570 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7571 (if lastline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7572 ;; A hline: simulate an empty table row instead.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7573 (setq line (org-fake-empty-table-line lastline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7574 head nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7575 empty "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7576 ;; Ignore this line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7577 (throw 'next-line t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7578 ;; Break the line into fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7579 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7580 (setq html (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7581 html
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7582 "<tr>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7583 (mapconcat (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7584 (if (equal x "") (setq x empty))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7585 (if head
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7586 (concat "<th>" x "</th>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7587 (concat "<td valign=\"top\">" x "</td>")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7588 fields "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7589 "</tr>\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7590 (setq html (concat html "</table>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7591 html))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7592
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7593 (defun org-fake-empty-table-line (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7594 "Replace everything except \"|\" with spaces."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7595 (let ((i (length line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7596 (newstr (copy-sequence line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7597 (while (> i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7598 (setq i (1- i))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7599 (if (not (eq (aref newstr i) ?|))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7600 (aset newstr i ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7601 newstr))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7602
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7603 (defun org-format-table-table-html (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7604 "Format a table generated by table.el into html.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7605 This conversion does *not* use `table-generate-source' from table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7606 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
7607 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
7608 (let (line field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7609 (head org-export-highlight-first-table-line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7610 fields html empty)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7611 (setq html (concat org-export-html-table-tag "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7612 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7613 (setq empty "&nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7614 (catch 'next-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7615 (if (string-match "^[ \t]*\\+-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7616 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7617 (if field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7618 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7619 (setq html (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7620 html
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7621 "<tr>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7622 (mapconcat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7623 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7624 (if (equal x "") (setq x empty))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7625 (if head
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7626 (concat "<th valign=\"top\">" x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7627 "</th>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7628 (concat "<td valign=\"top\">" x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7629 "</td>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7630 field-buffer "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7631 "</tr>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7632 (setq head nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7633 (setq field-buffer nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7634 ;; Ignore this line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7635 (throw 'next-line t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7636 ;; Break the line into fields and store the fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7637 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7638 (if field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7639 (setq field-buffer (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7640 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7641 (concat x "<br>" (pop fields)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7642 field-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7643 (setq field-buffer fields))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7644 (setq html (concat html "</table>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7645 html))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7646
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7647 (defun org-format-table-table-html-using-table-generate-source (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7648 "Format a table into html, using `table-generate-source' from table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7649 This has the advantage that cell- or row-spanning is allowed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7650 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
7651 (require 'table)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7652 (with-current-buffer (get-buffer-create " org-tmp1 ")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7653 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7654 (insert (mapconcat 'identity lines "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7655 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7656 (if (not (re-search-forward "|[^+]" nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7657 (error "Error processing table."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7658 (table-recognize-table)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7659 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7660 (table-generate-source 'html " org-tmp2 ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7661 (set-buffer " org-tmp2 ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7662 (buffer-substring (point-min) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7663
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7664 (defun org-html-expand (string)
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
7665 "Prepare STRING for HTML export. Applies all active conversions."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7666 ;; 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
7667 ;; only before the start of the link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7668 (let* ((m (string-match org-link-regexp string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7669 (s (if m (substring string 0 m) string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7670 (r (if m (substring string m) "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7671 ;; convert < to &lt; and > to &gt;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7672 (while (string-match "<" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7673 (setq s (replace-match "&lt;" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7674 (while (string-match ">" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7675 (setq s (replace-match "&gt;" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7676 (if org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7677 (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7678 (setq s (replace-match "<\\1>" nil nil s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7679 (if org-export-with-emphasize
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7680 (setq s (org-export-html-convert-emphasize s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7681 (if org-export-with-sub-superscripts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7682 (setq s (org-export-html-convert-sub-super s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7683 (if org-export-with-TeX-macros
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7684 (let ((start 0) wd ass)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7685 (while (setq start (string-match "\\\\\\([a-zA-Z]+\\)" s start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7686 (setq wd (match-string 1 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7687 (if (setq ass (assoc wd org-html-entities))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7688 (setq s (replace-match (or (cdr ass)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7689 (concat "&" (car ass) ";"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7690 t t s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7691 (setq start (+ start (length wd)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7692 (concat s r)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7693
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7694 (defun org-create-multibrace-regexp (left right n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7695 "Create a regular expression which will match a balanced sexp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7696 Opening delimiter is LEFT, and closing delimiter is RIGHT, both given
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7697 as single character strings.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7698 The regexp returned will match the entire expression including the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7699 delimiters. It will also define a single group which contains the
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
7700 match except for the outermost delimiters. The maximum depth of
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
7701 stacked delimiters is N. Escaping delimiters is not possible."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7702 (let* ((nothing (concat "[^" "\\" left "\\" right "]*?"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7703 (or "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7704 (re nothing)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7705 (next (concat "\\(?:" nothing left nothing right "\\)+" nothing)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7706 (while (> n 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7707 (setq n (1- n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7708 re (concat re or next)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7709 next (concat "\\(?:" nothing left next right "\\)+" nothing)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7710 (concat left "\\(" re "\\)" right)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7711
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7712 (defvar org-match-substring-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7713 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7714 "\\([^\\]\\)\\([_^]\\)\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7715 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7716 "\\|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7717 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7718 "\\|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7719 "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7720 "The regular expression matching a sub- or superscript.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7721
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7722 (defun org-export-html-convert-sub-super (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7723 "Convert sub- and superscripts in STRING to HTML."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7724 (let (key c)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7725 (while (string-match org-match-substring-regexp string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7726 (setq key (if (string= (match-string 2 string) "_") "sub" "sup"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7727 (setq c (or (match-string 8 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7728 (match-string 6 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7729 (match-string 5 string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7730 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7731 (concat (match-string 1 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7732 "<" key ">" c "</" key ">")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7733 t t string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7734 (while (string-match "\\\\\\([_^]\\)" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7735 (setq string (replace-match (match-string 1 string) t t string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7736 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7737
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7738 (defun org-export-html-convert-emphasize (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7739 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7740 "\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7741 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7742 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7743 (concat "<b>" (match-string 3 string) "</b>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7744 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7745 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7746 "\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7747 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7748 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7749 (concat "<i>" (match-string 3 string) "</i>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7750 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7751 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7752 "\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7753 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7754 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7755 (concat "<u>" (match-string 3 string) "</u>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7756 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7757 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7758
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7759 (defun org-parse-key-lines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7760 "Find the special key lines with the information for exporters."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7761 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7762 (goto-char 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7763 (let ((re (org-make-options-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7764 '("TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7765 key)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7766 (while (re-search-forward re nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7767 (setq key (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7768 (cond ((string-equal key "TITLE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7769 (setq title (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7770 ((string-equal key "AUTHOR")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7771 (setq author (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7772 ((string-equal key "EMAIL")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7773 (setq email (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7774 ((string-equal key "LANGUAGE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7775 (setq language (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7776 ((string-equal key "TEXT")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7777 (setq text (concat text "\n" (match-string 2))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7778 ((string-equal key "OPTIONS")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7779 (setq options (match-string 2))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7780
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7781 (defun org-parse-export-options (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7782 "Parse the export options line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7783 (let ((op '(("H" . org-export-headline-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7784 ("num" . org-export-with-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7785 ("toc" . org-export-with-toc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7786 ("\\n" . org-export-preserve-breaks)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7787 ("@" . org-export-html-expand)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7788 (":" . org-export-with-fixed-width)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7789 ("|" . org-export-with-tables)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7790 ("^" . org-export-with-sub-superscripts)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7791 ("*" . org-export-with-emphasize)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7792 ("TeX" . org-export-with-TeX-macros)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7793 o)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7794 (while (setq o (pop op))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7795 (if (string-match (concat (regexp-quote (car o)) ":\\([^ \t\n\r;,.]*\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7796 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7797 (set (make-local-variable (cdr o))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7798 (car (read-from-string (match-string 1 s))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7799
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7800 (defun org-html-level-start (level title umax with-toc head-count)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7801 "Insert a new level in HTML export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7802 (let ((l (1+ (max level umax))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7803 (while (<= l org-level-max)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7804 (if (aref levels-open (1- l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7805 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7806 (org-html-level-close l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7807 (aset levels-open (1- l) nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7808 (setq l (1+ l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7809 (if (> level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7810 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7811 (if (aref levels-open (1- level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7812 (insert "<li>" title "<p>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7813 (aset levels-open (1- level) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7814 (insert "<ul><li>" title "<p>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7815 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7816 (setq title (concat (org-section-number level) " " title)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7817 (setq level (+ level 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7818 (if with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7819 (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
7820 level head-count title level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7821 (insert (format "\n<H%d>%s</H%d>\n" level title level))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7822
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7823 (defun org-html-level-close (&rest args)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7824 "Terminate one level in HTML export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7825 (insert "</ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7826
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 ;; Variable holding the vector with section numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7829 (defvar org-section-numbers (make-vector org-level-max 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7830
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7831 (defun org-init-section-numbers ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7832 "Initialize the vector for the section numbers."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7833 (let* ((level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7834 (numbers (nreverse (org-split-string "" "\\.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7835 (depth (1- (length org-section-numbers)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7836 (i depth) number-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7837 (while (>= i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7838 (if (> i level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7839 (aset org-section-numbers i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7840 (setq number-string (or (car numbers) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7841 (if (string-match "\\`[A-Z]\\'" number-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7842 (aset org-section-numbers i
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7843 (- (string-to-char number-string) ?A -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7844 (aset org-section-numbers i (string-to-int number-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7845 (pop numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7846 (setq i (1- i)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7847
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7848 (defun org-section-number (&optional level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7849 "Return a string with the current section number.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7850 When LEVEL is non-nil, increase section numbers on that level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7851 (let* ((depth (1- (length org-section-numbers))) idx n (string ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7852 (when level
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7853 (when (> level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7854 (aset org-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7855 level (1+ (aref org-section-numbers level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7856 (setq idx (1+ level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7857 (while (<= idx depth)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7858 (if (not (= idx 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7859 (aset org-section-numbers idx 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7860 (setq idx (1+ idx))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7861 (setq idx 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7862 (while (<= idx depth)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7863 (setq n (aref org-section-numbers idx))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7864 (setq string (concat string (if (not (string= string "")) "." "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7865 (int-to-string n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7866 (setq idx (1+ idx)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7867 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7868 (if (string-match "\\`\\([@0]\\.\\)+" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7869 (setq string (replace-match "" nil nil string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7870 (if (string-match "\\(\\.0\\)+\\'" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7871 (setq string (replace-match "" nil nil string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7872 string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7873
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7874
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7875 ;;; Key bindings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7876
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7877 ;; - Bindings in Org-mode map are currently
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7878 ;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7879 ;; abcd fgh j lmnopqrstuvwxyz ? # -+ /= [] ; |,.<> \t necessary bindings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7880 ;; e (?) useful from outline-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7881 ;; i k @ expendable from outline-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7882 ;; 0123456789 ! $%^& * ()_{} " ~`' free
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7883
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7884 (define-key org-mode-map [(tab)] 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7885 (define-key org-mode-map "\C-i" 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7886 (define-key org-mode-map [(meta tab)] 'org-complete)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7887 (define-key org-mode-map "\M-\C-i" 'org-complete)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7888 (define-key org-mode-map [(meta shift left)] 'org-shiftmetaleft)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7889 (define-key org-mode-map [(meta left)] 'org-metaleft)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7890 (define-key org-mode-map [(meta shift right)] 'org-shiftmetaright)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7891 (define-key org-mode-map [(meta shift up)] 'org-shiftmetaup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7892 (define-key org-mode-map [(meta shift down)] 'org-shiftmetadown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7893 (define-key org-mode-map [(meta right)] 'org-metaright)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7894 (define-key org-mode-map [(meta up)] 'org-metaup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7895 (define-key org-mode-map [(meta down)] 'org-metadown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7896 ;(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
7897 ;(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
7898 ;(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
7899 (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
7900 (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
7901 (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
7902 (define-key org-mode-map "\C-c\C-j" 'org-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7903 (define-key org-mode-map "\C-c\C-t" 'org-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7904 (define-key org-mode-map "\C-c\C-s" 'org-schedule)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7905 (define-key org-mode-map "\C-c\C-d" 'org-deadline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7906 (define-key org-mode-map "\C-c;" 'org-toggle-comment)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7907 (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
7908 (define-key org-mode-map "\C-c\C-w" 'org-check-deadlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7909 (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7910 (define-key org-mode-map "\C-c\C-m" 'org-insert-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7911 (define-key org-mode-map "\M-\C-m" 'org-insert-heading)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7912 (define-key org-mode-map [(meta shift return)] 'org-insert-todo-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7913 (define-key org-mode-map "\C-c\C-l" 'org-insert-link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7914 (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
7915 (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
7916 (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
7917 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7918 (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
7919 (define-key org-mode-map "\C-c>" 'org-goto-calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7920 (define-key org-mode-map "\C-c<" 'org-date-from-calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7921 (define-key org-mode-map "\C-c[" 'org-add-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7922 (define-key org-mode-map "\C-c]" 'org-remove-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7923 (define-key org-mode-map "\C-c\C-r" 'org-timeline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7924 (define-key org-mode-map [(shift up)] 'org-shiftup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7925 (define-key org-mode-map [(shift down)] 'org-shiftdown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7926 (define-key org-mode-map [(shift left)] 'org-timestamp-down-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7927 (define-key org-mode-map [(shift right)] 'org-timestamp-up-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7928 (define-key org-mode-map "\C-c-" 'org-table-insert-hline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7929 ;; 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
7930 (unless org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7931 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7932 (define-key org-mode-map [(shift tab)] 'org-shifttab)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7933 (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
7934 (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
7935 (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
7936 (define-key org-mode-map [(meta return)] 'org-meta-return)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7937 (define-key org-mode-map [(control up)] 'org-move-line-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7938 (define-key org-mode-map [(control down)] 'org-move-line-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7939 (define-key org-mode-map "\C-c?" 'org-table-current-column)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7940 (define-key org-mode-map "\C-c " 'org-table-blank-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7941 (define-key org-mode-map "\C-c+" 'org-table-sum)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7942 (define-key org-mode-map "\C-c|" 'org-table-toggle-vline-visibility)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7943 (define-key org-mode-map "\C-c=" 'org-table-eval-formula)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7944 (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
7945 (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
7946 (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
7947 (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
7948 (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
7949 (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-copy-visible)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7950 ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7951 ;(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
7952 (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
7953 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7954 (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
7955 (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
7956
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7957
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7958 ;; 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
7959 ;; 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
7960 ;; 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
7961
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7962 (defsubst org-table-p ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7963 (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
7964 (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
7965 (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
7966
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7967 (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
7968 "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
7969 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
7970 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
7971 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7972 (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
7973 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7974 (looking-at "[^|\n]* +|"))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
7975 (let (org-table-may-need-update)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7976 (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
7977 (delete-backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7978 (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
7979 (self-insert-command N))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7980 (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
7981 (self-insert-command N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7982
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7983 ;; FIXME:
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7984 ;; 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
7985 ;; 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
7986
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7987 (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
7988 "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
7989 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
7990 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
7991 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
7992 reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7993 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7994 (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
7995 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7996 (looking-at ".*?|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7997 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7998 (backward-delete-char N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7999 (skip-chars-forward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8000 (insert " ")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8001 (goto-char (1- pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8002 (backward-delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8003
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8004 (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
8005 "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
8006 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
8007 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
8008 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
8009 a reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8010 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8011 (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
8012 (eq N 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8013 (if (looking-at ".*?|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8014 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8015 (replace-match (concat
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8016 (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
8017 " |"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8018 (goto-char pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8019 (delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8020
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8021 ;; 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
8022 ;; 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
8023
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8024 (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
8025 ;; 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
8026 ;; some standard editing functions
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8027 (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
8028 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
8029 (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
8030 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
8031 (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
8032 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
8033 (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
8034
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8035 (defun org-shiftcursor-error ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8036 "Throw an error because Shift-Cursor command was applied in wrong context."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8037 (error "This command is only active in tables and on headlines."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8038
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8039 (defun org-shifttab ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8040 "Call `(org-cycle t)' or `org-table-previous-field'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8041 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8042 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8043 ((org-at-table-p) (org-table-previous-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8044 (t (org-cycle '(4)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8045
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8046 (defun org-shiftmetaleft ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8047 "Call `org-promote-subtree' or `org-table-delete-column'."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8048 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8049 (cond
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8050 ((org-at-table-p) (org-table-delete-column))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8051 ((org-on-heading-p) (org-promote-subtree))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8052 (t (org-shiftcursor-error))))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8053
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8054 (defun org-shiftmetaright ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8055 "Call `org-demote-subtree' or `org-table-insert-column'."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8056 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8057 (cond
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8058 ((org-at-table-p) (org-table-insert-column))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8059 ((org-on-heading-p) (org-demote-subtree))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8060 (t (org-shiftcursor-error))))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8061
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8062 (defun org-shiftmetaup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8063 "Call `org-move-subtree-up' or `org-table-kill-row'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8064 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8065 (cond
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8066 ((org-at-table-p) (org-table-kill-row))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8067 ((org-on-heading-p) (org-move-subtree-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8068 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8069 (defun org-shiftmetadown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8070 "Call `org-move-subtree-down' or `org-table-insert-row'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8071 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8072 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8073 ((org-at-table-p) (org-table-insert-row arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8074 ((org-on-heading-p) (org-move-subtree-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8075 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8076
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8077 (defun org-metaleft (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8078 "Call `org-do-promote' or `org-table-move-column' to left."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8079 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8080 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8081 ((org-at-table-p) (org-table-move-column 'left))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8082 ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8083 (t (backward-word (prefix-numeric-value arg)))))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8084
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8085 (defun org-metaright (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8086 "Call `org-do-demote' or `org-table-move-column' to right."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8087 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8088 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8089 ((org-at-table-p) (org-table-move-column nil))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8090 ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8091 (t (forward-word (prefix-numeric-value arg)))))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8092
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8093 (defun org-metaup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8094 "Call `org-move-subtree-up' or `org-table-move-row' up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8095 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8096 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8097 ((org-at-table-p) (org-table-move-row 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8098 ((org-on-heading-p) (org-move-subtree-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8099 (t (org-shiftcursor-error))))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8100
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8101 (defun org-metadown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8102 "Call `org-move-subtree-down' or `org-table-move-row' down."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8103 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8104 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8105 ((org-at-table-p) (org-table-move-row nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8106 ((org-on-heading-p) (org-move-subtree-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8107 (t (org-shiftcursor-error))))
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 (defun org-shiftup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8110 "Call `org-timestamp-up' or `org-priority-up'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8111 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8112 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8113 ((org-at-timestamp-p) (org-timestamp-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8114 (t (org-priority-up))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8115
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8116 (defun org-shiftdown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8117 "Call `org-timestamp-down' or `org-priority-down'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8118 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8119 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8120 ((org-at-timestamp-p) (org-timestamp-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8121 (t (org-priority-down))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8122
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8123 (defun org-copy-special ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8124 "Call either `org-table-copy' or `org-copy-subtree'."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8125 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8126 (if (org-at-table-p)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8127 (org-table-copy-region)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8128 (org-copy-subtree)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8129
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8130 (defun org-cut-special ()
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8131 "Call either `org-table-copy' or `org-cut-subtree'."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8132 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8133 (if (org-at-table-p)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8134 (org-table-cut-region)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8135 (org-cut-subtree)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8136
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8137 (defun org-paste-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8138 "Call either `org-table-paste-rectangle' or `org-paste-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8139 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8140 (if (org-at-table-p)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8141 (org-table-paste-rectangle)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8142 (org-paste-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8143
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8144 (defun org-ctrl-c-ctrl-c (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8145 "Call realign table, or recognize a table.el table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8146 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
8147 activate that table. Otherwise, if the cursor is at a normal table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8148 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
8149 the automatic table editor has been turned off."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8150 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8151 (let ((org-enable-table-editor t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8152 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8153 ((org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8154 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8155 (beginning-of-line 1)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8156 (re-search-forward "|" (save-excursion (end-of-line 2) (point))) ;FIXME: line-end-position?
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8157 (table-recognize-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8158 ((org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8159 (org-table-align))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8160 ((save-excursion (beginning-of-line 1) (looking-at "#\\+[A-Z]+"))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8161 (let ((org-inhibit-startup t)) (org-mode)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8162 ((org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8163 (org-table-convert-region (region-beginning) (region-end) arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8164 ((and (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8165 (if (y-or-n-p "Convert inactive region to table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8166 (org-table-convert-region (region-beginning) (region-end) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8167 (error "Abort")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8168 (t (error "No table at point, and no region to make one.")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8169
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8170 (defun org-return ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8171 "Call `org-table-next-row' or `newline'."
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8172 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8173 (cond
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8174 ((org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8175 (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
8176 (org-table-next-row))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8177 (t (newline))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8178
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8179 (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
8180 "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
8181 (interactive "P")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8182 (cond
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8183 ((org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8184 (org-table-wrap-region arg))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8185 (t (org-insert-heading))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8186
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8187 ;;; Menu entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8188
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8189 ;; First, remove the outline menus.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8190 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8191 (add-hook 'org-mode-hook
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8192 (lambda ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8193 (delete-menu-item '("Headings"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8194 (delete-menu-item '("Show"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8195 (delete-menu-item '("Hide"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8196 (set-menubar-dirty-flag)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8197 (setq org-mode-map (delq (assoc 'menu-bar (cdr org-mode-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8198 org-mode-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8199
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8200 ;; Define the Org-mode menus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8201 (easy-menu-define org-org-menu org-mode-map "Org menu"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8202 '("Org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8203 ["Cycle Visibility" org-cycle (or (bobp) (outline-on-heading-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8204 ["Sparse Tree" org-occur t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8205 ["Show All" show-all t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8206 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8207 ["New Heading" org-insert-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8208 ("Navigate Headings"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8209 ["Up" outline-up-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8210 ["Next" outline-next-visible-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8211 ["Previous" outline-previous-visible-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8212 ["Next Same Level" outline-forward-same-level t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8213 ["Previous Same Level" outline-backward-same-level t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8214 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8215 ["Jump" org-goto t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8216 ("Edit Structure"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8217 ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8218 ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))]
58792
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 ["Copy Subtree" org-copy-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8221 ["Cut Subtree" org-cut-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8222 ["Paste Subtree" org-paste-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8223 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8224 ["Promote Heading" org-metaleft (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8225 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8226 ["Demote Heading" org-metaright (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8227 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8228 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8229 ("TODO Lists"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8230 ["TODO/DONE/-" org-todo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8231 ["Show TODO Tree" org-show-todo-tree t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8232 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8233 ["Set Priority" org-priority t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8234 ["Priority Up" org-shiftup t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8235 ["Priority Down" org-shiftdown t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8236 ("Dates and Scheduling"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8237 ["Timestamp" org-time-stamp t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8238 ("Change Date"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8239 ["1 Day Later" org-timestamp-up-day t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8240 ["1 Day Earlier" org-timestamp-down-day t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8241 ["1 ... Later" org-shiftup t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8242 ["1 ... Earlier" org-shiftdown t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8243 ["Compute Time Range" org-evaluate-time-range t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8244 ["Schedule Item" org-schedule t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8245 ["Deadline" org-deadline t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8246 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8247 ["Goto Calendar" org-goto-calendar t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8248 ["Date from Calendar" org-date-from-calendar t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8249 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8250 ("Timeline/Agenda"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8251 ["Show TODO Tree this File" org-show-todo-tree t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8252 ["Check Deadlines this File" org-check-deadlines t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8253 ["Timeline Current File" org-timeline t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8254 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8255 ["Agenda" org-agenda t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8256 ("File List for Agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8257 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8258 ("Hyperlinks"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8259 ["Store Link (Global)" org-store-link t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8260 ["Insert Link" org-insert-link t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8261 ["Follow Link" org-open-at-point t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8262 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8263 ("Table"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8264 ["Align" org-ctrl-c-ctrl-c (org-at-table-p)]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8265 ["Next Field" org-cycle (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8266 ["Previous Field" org-shifttab (org-at-table-p)]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8267 ["Next Row" org-return (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8268 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8269 ["Blank Field" org-table-blank-field (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8270 ["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
8271 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8272 ("Column"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8273 ["Move Column Left" org-metaleft (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8274 ["Move Column Right" org-metaright (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8275 ["Delete Column" org-shiftmetaleft (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8276 ["Insert Column" org-shiftmetaright (org-at-table-p)])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8277 ("Row"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8278 ["Move Row Up" org-metaup (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8279 ["Move Row Down" org-metadown (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8280 ["Delete Row" org-shiftmetaup (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8281 ["Insert Row" org-shiftmetadown (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8282 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8283 ["Insert Hline" org-table-insert-hline (org-at-table-p)])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8284 ("Rectangle"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8285 ["Copy Rectangle" org-copy-special (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8286 ["Cut Rectangle" org-cut-special (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8287 ["Paste Rectangle" org-paste-special (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8288 ["Fill Rectangle" org-table-wrap-region (org-at-table-p)])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8289 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8290 ["Which Column?" org-table-current-column (org-at-table-p)]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8291 ["Sum Column/Rectangle" org-table-sum
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8292 (or (org-at-table-p) (org-region-active-p))]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8293 ["Eval Formula" org-table-eval-formula (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8294 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8295 ["Invisible Vlines" org-table-toggle-vline-visibility
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8296 :style toggle :selected (org-in-invisibility-spec-p '(org-table))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8297 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8298 ["Create" org-table-create (and (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8299 org-enable-table-editor)]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8300 ["Convert Region" org-ctrl-c-ctrl-c (not (org-at-table-p 'any))]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8301 ["Import from File" org-table-import (not (org-at-table-p))]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8302 ["Export to File" org-table-export (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8303 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8304 ["Create/Convert from/to table.el" org-table-create-with-table.el t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8305 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8306 ("Export"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8307 ["ASCII" org-export-as-ascii t]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8308 ["Extract Visible Text" org-export-copy-visible t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8309 ["HTML" org-export-as-html t]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8310 ["HTML and Open" org-export-as-html-and-open t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8311 ; ["OPML" org-export-as-opml nil]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8312 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8313 ["Option Template" org-insert-export-options-template t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8314 ["Toggle Fixed Width" org-toggle-fixed-width-section t])
58792
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 ("Documentation"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8317 ["Show Version" org-version t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8318 ["Info Documentation" org-info t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8319 ("Customize"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8320 ["Browse Org Group" org-customize t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8321 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8322 ["Build Full Customize Menu" org-create-customize-menu
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8323 (fboundp 'customize-menu-create)])
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
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8326 (defun org-info (&optional node)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8327 "Read documentation for Org-mode in the info system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8328 With optional NODE, go directly to that node."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8329 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8330 (require 'info)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8331 (Info-goto-node (format "(org)%s" (or node ""))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8332
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8333 (defun org-install-agenda-files-menu ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8334 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8335 '("Org") "File List for Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8336 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8337 (list
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8338 ["Edit File List" (customize-variable 'org-agenda-files) t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8339 ["Add Current File to List" org-add-file t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8340 ["Remove Current File from List" org-remove-file t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8341 "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8342 (mapcar 'org-file-menu-entry org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8343
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8344 ;;; Documentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8345
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8346 (defun org-customize ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8347 "Call the customize function with org as argument."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8348 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8349 (customize-browse 'org))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8350
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8351 (defun org-create-customize-menu ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8352 "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
8353 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8354 (if (fboundp 'customize-menu-create)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8355 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8356 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8357 '("Org") "Customize"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8358 `(["Browse Org group" org-customize t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8359 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8360 ,(customize-menu-create 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8361 ["Set" Custom-set t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8362 ["Save" Custom-save t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8363 ["Reset to Current" Custom-reset-current t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8364 ["Reset to Saved" Custom-reset-saved t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8365 ["Reset to Standard Settings" Custom-reset-standard t]))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8366 (message "\"Org\"-menu now contains full customization menu"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8367 (error "Cannot expand menu (outdated version of cus-edit.el)")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8368
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8369 ;;; Miscellaneous stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8370
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8371 (defun org-move-line-down (arg)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8372 "Move the current line down. With prefix argument, move it past ARG lines."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8373 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8374 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8375 beg end pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8376 (beginning-of-line 1) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8377 (beginning-of-line 2) (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8378 (beginning-of-line (+ 1 arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8379 (setq pos (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8380 (insert (delete-and-extract-region beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8381 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8382 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8383
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8384 (defun org-move-line-up (arg)
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8385 "Move the current line up. With prefix argument, move it past ARG lines."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8386 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8387 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8388 beg end pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8389 (beginning-of-line 1) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8390 (beginning-of-line 2) (setq end (point))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8391 (beginning-of-line (- arg))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8392 (setq pos (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8393 (insert (delete-and-extract-region beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8394 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8395 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8396
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8397 ;; Functions needed for Emacs/XEmacs region compatibility
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8398
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8399 (defun org-region-active-p ()
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8400 "Is `transient-mark-mode' on and the region active?
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8401 Works on both Emacs and XEmacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8402 (if org-ignore-region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8403 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8404 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8405 (and zmacs-regions (region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8406 (and transient-mark-mode mark-active))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8407
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8408 (defun org-add-to-invisibility-spec (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8409 "Add elements to `buffer-invisibility-spec'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8410 See documentation for `buffer-invisibility-spec' for the kind of elements
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8411 that can be added."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8412 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8413 ((fboundp 'add-to-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8414 (add-to-invisibility-spec arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8415 ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8416 (setq buffer-invisibility-spec (list arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8417 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8418 (setq buffer-invisibility-spec
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8419 (cons arg buffer-invisibility-spec)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8420
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8421 (defun org-remove-from-invisibility-spec (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8422 "Remove elements from `buffer-invisibility-spec'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8423 (if (fboundp 'remove-from-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8424 (remove-from-invisibility-spec arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8425 (if (consp buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8426 (setq buffer-invisibility-spec
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8427 (delete arg buffer-invisibility-spec)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8428
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8429 (defun org-in-invisibility-spec-p (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8430 "Is ARG a member of `buffer-invisibility-spec'?."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8431 (if (consp buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8432 (member arg buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8433 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8434
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8435 (defun org-image-file-name-regexp ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8436 "Return regexp matching the file names of images."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8437 (if (fboundp 'image-file-name-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8438 (image-file-name-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8439 (let ((image-file-name-extensions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8440 '("png" "jpeg" "jpg" "gif" "tiff" "tif"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8441 "xbm" "xpm" "pbm" "pgm" "ppm")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8442 (concat "\\."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8443 (regexp-opt (nconc (mapcar 'upcase
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8444 image-file-name-extensions)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8445 image-file-name-extensions)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8446 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8447 "\\'"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8448
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8449 ;; Functions needed for compatibility with old outline.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8450
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8451 ;; The following functions capture almost the entire compatibility code
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8452 ;; between the different versions of outline-mode. The only other place
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8453 ;; where this is important are the font-lock-keywords. Search for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8454 ;; `org-noutline-p' to find it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8455
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8456 ;; 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
8457 ;; new outline.el. I guess this should be patched into Emacs?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8458 (defun org-beginning-of-line ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8459 "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
8460 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
8461 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8462 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8463 (if (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8464 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8465 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8466 (if (org-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8467 (while (and (not (bobp)) (org-invisible-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8468 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8469 (beginning-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8470 (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8471 (when org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8472 (define-key org-mode-map "\C-a" 'org-beginning-of-line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8473
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8474 (defun org-invisible-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8475 "Check if point is at a character currently not visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8476 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8477 ;; Early versions of noutline don't have `outline-invisible-p'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8478 (if (fboundp 'outline-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8479 (outline-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8480 (get-char-property (point) 'invisible))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8481 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8482 (skip-chars-backward "^\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8483 (if (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8484 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8485 (equal (char-before) ?\r)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8486
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8487 (defun org-back-to-heading (&optional invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8488 "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
8489 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8490 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8491 (outline-back-to-heading invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8492 (if (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8493 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8494 (if (re-search-backward (concat (if invisible-ok "[\r\n]" "^")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8495 outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8496 nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8497 (if invisible-ok
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8498 (progn (forward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8499 (looking-at outline-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8500 (error "Before first heading")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8501
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8502 (defun org-on-heading-p (&optional invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8503 "Return t if point is on a (visible) heading line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8504 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
8505 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8506 (outline-on-heading-p 'invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8507 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8508 (skip-chars-backward "^\n\r")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8509 (and (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8510 (or invisible-ok
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8511 (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8512 (equal (char-before) ?\n))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8513
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8514 (defun org-up-heading-all (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8515 "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
8516 This function considers both visible and invisible heading lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8517 With argument, move up ARG levels."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8518 (if org-noutline-p
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8519 (if (fboundp 'outline-up-heading-all)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8520 (outline-up-heading-all arg) ; emacs 21 version of outline.el
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8521 (outline-up-heading arg t)) ; emacs 22 version of outline.el
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8522 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8523 (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8524 (if (<= (- (match-end 0) (match-beginning 0)) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8525 (error "Cannot move up %d levels" arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8526 (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8527 (concat "[\n\r]" (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8528 (make-string (- (match-end 0) (match-beginning 0) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8529 ?*))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8530 "[^*]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8531 (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8532
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8533 (defun org-show-hidden-entry ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8534 "Show an entry where even the heading is hidden."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8535 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8536 (if (not org-noutline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8537 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8538 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8539 (org-flag-heading nil)))
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8540 (org-show-entry)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8541
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8542 (defun org-check-occur-regexp (regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8543 "If REGEXP starts with \"^\", modify it to check for \\r as well.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8544 Of course, only for the old outline mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8545 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8546 regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8547 (if (string-match "^\\^" regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8548 (concat "[\n\r]" (substring regexp 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8549 regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8550
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8551 (defun org-flag-heading (flag &optional entry)
62076
4f2150e05f24 (org-get-entries-from-diary): Remove unused vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61924
diff changeset
8552 "Flag the current heading. FLAG non-nil means make invisible.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8553 When ENTRY is non-nil, show the entire entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8554 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8555 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8556 (if (not org-noutline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8557 ;; Make the current headline visible
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8558 (outline-flag-region (max 1 (1- (point))) (point) (if flag ?\r ?\n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8559 ;; Check if we should show the entire entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8560 (if entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8561 (progn
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8562 (org-show-entry)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8563 (save-excursion ;; FIXME: Is this the fix for points in the -|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8564 ;; middle of text? |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8565 (and (outline-next-heading) ;; |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8566 (org-flag-heading nil)))) ; show the next heading _|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8567 (outline-flag-region (max 1 (1- (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8568 (save-excursion (outline-end-of-heading) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8569 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8570 flag
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8571 (if flag ?\r ?\n))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8572
61924
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8573 (defun org-show-subtree ()
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8574 "Show everything after this heading at deeper levels."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8575 (outline-flag-region
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8576 (point)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8577 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8578 (outline-end-of-subtree) (outline-next-heading) (point))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8579 (if org-noutline-p nil ?\n)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8580
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8581 (defun org-show-entry ()
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8582 "Show the body directly following this heading.
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8583 Show the heading too, if it is currently invisible."
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8584 (interactive)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8585 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8586 (org-back-to-heading t)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8587 (outline-flag-region
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8588 (1- (point))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8589 (save-excursion
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8590 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move)
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8591 (or (match-beginning 1) (point-max)))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8592 (if org-noutline-p nil ?\n))))
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8593
d29accb0274a Many small changes to keep the byte compiler happy. Furthermore:
Carsten Dominik <dominik@science.uva.nl>
parents: 61582
diff changeset
8594
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8595 (defun org-make-options-regexp (kwds)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8596 "Make a regular expression for keyword lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8597 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8598 (if org-noutline-p "^" "[\n\r]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8599 "#?[ \t]*\\+\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8600 (mapconcat 'regexp-quote kwds "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8601 "\\):[ \t]*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8602 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8603
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8604 ;; Advise the bookmark-jump function to make jump position visible
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8605 ;; Wrapped into eval-after-load to avoid loading advice unnecessarily
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8606 (eval-after-load "bookmark"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8607 '(defadvice bookmark-jump (after org-make-visible activate)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8608 "Make the position visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8609 (and (eq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8610 (org-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8611 (org-show-hierarchy-above))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8612
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8613 ;;; Finish up
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8614
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8615 (provide 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8616
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8617 (run-hooks 'org-load-hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8618
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8619 ;; 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
8620
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8621 ;;; org.el ends here
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8622