annotate lisp/textmodes/org.el @ 61694:5f68807dfb49

Check for <pwd.h>.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Wed, 20 Apr 2005 10:56:08 +0000
parents e0ff525f6d80
children d29accb0274a e1fbb019c538
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/
61561
55a8477186ea *** empty log message ***
Carsten Dominik <dominik@science.uva.nl>
parents: 61560
diff changeset
8 ;; Version: 3.06
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 ;; -------
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
82 ;; Version 3.06
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
83 ;; - 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
84 ;; - New startup option `content'.
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
85 ;; - 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
86 ;; - 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
87 ;; 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
88 ;;
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
89 ;; 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
90 ;; - 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
91 ;; 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
92 ;; - 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
93 ;; - 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
94 ;; - 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
95 ;; - 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
96 ;;
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
97 ;; Version 3.04
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
98 ;; - 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
99 ;; 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
100 ;; - 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
101 ;; into arbitrary major modes.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
102 ;; - 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
103 ;; - 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
104 ;; - 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
105 ;;
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; Version 3.03
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; - 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
108 ;; - 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
109 ;; - Timeline now always contains today, and `.' jumps to it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; - Table editor:
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
111 ;; - cut and paste of rectangular regions in tables
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; - command to convert org-mode table to table.el table and back
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; - command to treat several cells like a paragraph and fill it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; - command to convert a buffer region to a table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; - import/export tables as tab-separated files (exchange with Excel)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; - Agenda:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; - Sorting mechanism for agenda items rewritten from scratch.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; - Sorting fully configurable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; - Entries specifying a time are sorted together.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; - Completion also covers option keywords after `#-'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; - Bug fixes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; Version 3.01
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; - New reference card, thanks to Philip Rooke for creating it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; - Single file agenda renamed to "Timeline". It no longer shows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; warnings about upcoming deadlines/overdue scheduled items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; That functionality is now limited to the (multifile) agenda.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; - When reading a date, the calendar can be manipulated with keys.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; - Link support for RMAIL and Wanderlust (from planner.el, untested)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; - Minor bug fixes and documentation improvements.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;;; Code:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (eval-when-compile (require 'cl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (require 'outline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (require 'time-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (require 'easymenu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;;; Customization variables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
141 (defvar org-version "3.06"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 "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
143 (defun org-version ()
8e7a2f6f9fa7 (org-version): Unnecessary prefix arg removed.
Carsten Dominik <dominik@science.uva.nl>
parents: 59547
diff changeset
144 (interactive)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (message "Org-mode version %s" org-version))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; The following two constants are for compatibility with different
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;; Emacs versions (Emacs versus XEmacs) and with different versions of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; 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
150 ;; constants.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (defconst org-xemacs-p (featurep 'xemacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "Are we running xemacs?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (defconst org-noutline-p (featurep 'noutline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 "Are we using the new outline mode?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (defgroup org nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 "Outline-based notes management and organizer "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 :tag "Org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 :group 'outlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 :group 'hypermedia
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 :group 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (defgroup org-startup nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 "Options concerning startup of Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 :tag "Org Startup"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (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
169 "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
170 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
171 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
172
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
173 #+STARTUP: fold
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
174 #+STARTUP: nofold
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
175 #+STARTUP: content"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 :group 'org-startup
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
177 :type '(choice
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
178 (const :tag "nofold: show all" nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
179 (const :tag "fold: overview" t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
180 (const :tag "content: all headlines" content)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (defcustom org-startup-truncated t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 "Non-nil means, entering Org-mode will set `truncate-lines'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 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
185 uninteresting. Also tables look terrible when wrapped."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (defcustom org-startup-with-deadline-check nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 "Non-nil means, entering Org-mode will run the deadline check.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 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
192 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
193 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
194 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
195
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
196 #+STARTUP: dlcheck
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
197 #+STARTUP: nodlcheck
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
198 "
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201
61312
6939a6683ac3 (org-diary-default-entry): Fixed call to
Carsten Dominik <dominik@science.uva.nl>
parents: 61134
diff changeset
202 (defcustom org-insert-mode-line-in-empty-file nil
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 "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
204 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
205 normally means that the file name does not automatically trigger Org-mode.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 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
207 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
208 has been set."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 :group 'org-startup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (defgroup org-keywords nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 "Options concerning TODO items in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 :tag "Org Keywords"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (defcustom org-todo-keywords '("TODO" "DONE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 "List of TODO entry keywords.\\<org-mode-map>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 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
221 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
222 etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 The command \\[org-todo] cycles an entry through these states, and an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 additional state where no keyword is present. For details about this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 cycling, see also the variable `org-todo-interpretation'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 :type '(repeat (string :tag "Keyword")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (defcustom org-todo-interpretation 'sequence
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 "Controls how TODO keywords are interpreted.\\<org-mode-map>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 Possible values are `sequence' and `type'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 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
234 states. There are two ways how these keywords can be used:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 - 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
237 (setq org-todo-keywords '(\"TODO\" \"STARTED\" \"VERIFY\" \"DONE\")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 - As different types of TODO items, for example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (setq org-todo-keywords '(\"URGENT\" \"RELAXED\" \"REMIND\" \"FOR_TOM\" \"DONE\")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 org-todo-interpretation 'type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 When the states are interpreted as a sequence, \\[org-todo] always cycles
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 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
246 \\[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
247 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
248 later to VERIFY and finally to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 When the states are interpreted as types, \\[org-todo] still cycles through
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 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
252 select the type. However, if not called immediately after a previous
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 \\[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
254 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
255 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
256 RELAXED will not be changed REMIND, but directly to DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 You can create a large number of types. To initially select a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 type, it is then best to use C-u \\[org-todo] in order to specify the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 type with completion. Of course, you can also type the keyword
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 directly into the buffer. M-TAB completes TODO keywords at the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 beginning of a headline."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 :type '(choice (const sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (const type)))
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 (defcustom org-default-priority ?B
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 "The default priority of TODO items.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 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
270 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 :type 'character)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (defcustom org-lowest-priority ?C
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 "The lowest priority of TODO items. A character like ?A, ?B etc."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 :type 'character)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (defcustom org-deadline-string "DEADLINE:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 "String to mark deadline entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 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
281 terminated by a colon. You can insert a schedule keyword and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 a timestamp with \\[org-deadline].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 Changes become only effective after restarting Emacs."
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 'string)
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-scheduled-string "SCHEDULED:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 "String to mark scheduled TODO entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 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
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-schedule].
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-comment-string "COMMENT"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 "Entries starting with this keyword will never be exported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 An entry can be toggled between COMMENT and normal with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 \\[org-toggle-comment].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 Changes become only effective after restarting Emacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (defcustom org-after-todo-state-change-hook nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 "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
306 The new state (a string with a todo keyword, or nil) is available in the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 lisp variable `state'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 :group 'org-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 :type 'hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 ;; Variables for pre-computed regular expressions, all buffer local
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (defvar org-todo-kwd-priority-p nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 "Do TODO items have priorities?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (make-variable-buffer-local 'org-todo-kwd-priority-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (defvar org-todo-kwd-max-priority nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 "Maximum priority of TODO items")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (make-variable-buffer-local 'org-todo-kwd-max-priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (defvar org-ds-keyword-length 12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 "Maximum length of the Deadline and SCHEDULED keywords.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (make-variable-buffer-local 'org-ds-keyword-length)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (defvar org-done-string nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 "The last string in `org-todo-keywords', indicating an item is DONE.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (make-variable-buffer-local 'org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (defvar org-todo-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 "Matches any of the TODO state keywords.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (make-variable-buffer-local 'org-todo-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (defvar org-not-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 "Matches any of the TODO state keywords except the last one.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (make-variable-buffer-local 'org-not-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (defvar org-todo-line-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 "Matches a headline and puts TODO state into group 2 if present.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (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
333 (defvar org-nl-done-regexp nil
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 "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
335 (make-variable-buffer-local 'org-nl-done-regexp)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (defvar org-looking-at-done-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 "Matches the DONE keyword a point.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (make-variable-buffer-local 'org-looking-at-done-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (defvar org-deadline-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 "Matches the DEADLINE keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (make-variable-buffer-local 'org-deadline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (defvar org-deadline-time-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 "Matches the DEADLINE keyword together with a time stamp.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (make-variable-buffer-local 'org-deadline-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (defvar org-deadline-line-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 "Matches the DEADLINE keyword and the rest of the line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (make-variable-buffer-local 'org-deadline-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (defvar org-scheduled-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 "Matches the SCHEDULED keyword.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (make-variable-buffer-local 'org-scheduled-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (defvar org-scheduled-time-regexp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 "Matches the SCHEDULED keyword together with a time stamp.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (make-variable-buffer-local 'org-scheduled-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
355 (defun org-set-regexps-and-options ()
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 "Precompute regular expressions for current buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (when (eq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (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
359 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (splitre "[ \t]+")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 kwds int key value cat)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (while (re-search-forward re nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (setq key (match-string 1) value (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 ((equal key "CATEGORY")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
370 (if (string-match "[ \t]+$" value)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
371 (setq value (replace-match "" t t value)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
372 (setq cat (intern value)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 ((equal key "SEQ_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (setq int 'sequence
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 kwds (append kwds (org-split-string value splitre))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 ((equal key "PRI_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (setq int 'priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 kwds (append kwds (org-split-string value splitre))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 ((equal key "TYP_TODO")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (setq int 'type
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
381 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
382 ((equal key "STARTUP")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
383 (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
384 (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
385 ("nofold" org-startup-folded nil)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
386 ("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
387 ("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
388 ("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
389 l var val)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
390 (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
391 (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
392 (set (make-local-variable var) val)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (and cat (set (make-local-variable 'org-category) cat))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (and kwds (set (make-local-variable 'org-todo-keywords) kwds))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (and int (set (make-local-variable 'org-todo-interpretation) int)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 ;; Compute the regular expressions and other local variables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 org-todo-kwd-max-priority (1- (length org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 org-ds-keyword-length (+ 2 (max (length org-deadline-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (length org-scheduled-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 org-done-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (nth (1- (length org-todo-keywords)) org-todo-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 org-todo-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 "\\|") "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 org-not-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (concat "\\<\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (mapconcat 'regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (nreverse (cdr (reverse org-todo-keywords)))
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 "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 org-todo-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (concat "^\\(\\*+\\)[ \t]*\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (mapconcat 'regexp-quote org-todo-keywords "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 "\\)? *\\(.*\\)")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
417 org-nl-done-regexp
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 org-looking-at-done-regexp (concat "^" org-done-string "\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 org-deadline-regexp (concat "\\<" org-deadline-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 org-deadline-time-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 org-deadline-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (concat "\\<\\(" org-deadline-string "\\).*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 org-scheduled-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (concat "\\<" org-scheduled-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 org-scheduled-time-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (org-set-font-lock-defaults)))
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 (defgroup org-time nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 "Options concerning time stamps and deadlines in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 :tag "Org Time"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (defcustom org-deadline-warning-days 30
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 "No. of days before expiration during which a deadline becomes active.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 This variable governs the display in the org file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (defcustom org-popup-calendar-for-date-prompt t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 "Non-nil means, pop up a calendar when prompting for a date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 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
445 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
446 When nil, only the minibuffer will be available."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (defcustom org-calendar-follow-timestamp-change t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 "Non-nil means, make the calendar window follow timestamp changes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 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
453 moved to the new date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 :group 'org-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (defgroup org-agenda nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 "Options concerning agenda display Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 :tag "Org Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (defcustom org-agenda-files nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 "A list of org files for agenda/diary display.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 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
465 \\[org-remove-file]. You can also use customize to edit the list."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 :type '(repeat file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (defcustom org-select-timeline-window t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 "Non-nil means, after creating a timeline, move cursor into Timeline window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 When nil, cursor will remain in the current window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 :group 'org-agenda
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 (defcustom org-select-agenda-window t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 "Non-nil means, after creating an agenda, move cursor into Agenda window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 When nil, cursor will remain in the current window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
481 (defcustom org-fit-agenda-window t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
482 "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
483 :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
484 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
485
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (defcustom org-agenda-show-all-dates t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 "Non-nil means, `org-agenda' shows every day in the selected range.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 When nil, only the days which actually have entries are shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 ;; 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
493 ;; require a variable ndays treatment.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (defcustom org-agenda-start-on-weekday 1
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 "Non-nil means, start the overview always on the specified weekday.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 0 Denotes Sunday, 1 denotes Monday etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 When nil, always start on the current day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 :type '(choice (const :tag "Today" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (const :tag "First day of month" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (number :tag "Weekday No.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (defcustom org-agenda-ndays 7
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 "Number of days to include in overview display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (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
509 "Non-nil means, the agenda will always contain all TODO entries.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 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
511 with a prefix argument.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 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
513 the entries for specific days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (defcustom org-agenda-include-diary nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 "Non-nil means, when preparing the agenda, also get the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 entries from the emacs calendars diary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
523 (defcustom org-calendar-to-agenda-key [?c]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
524 "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
525 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
526 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
527 force between agenda and calendar."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
528 :group 'org-agenda
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
529 :type 'sexp)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (defcustom org-agenda-sorting-strategy '(time-up category-keep priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 "Sorting structure for the agenda items of a single day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 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
534 if an entry should be listed before another entry. The following
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 symbols are recognized.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 time-up Put entries with time-of-day indications first, early first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 time-down Put entries with time-of-day indications first, late first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 category-keep Keep the default order of categories, corresponding to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 sequence in `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 category-up Sort alphabetically by category, A-Z.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 category-down Sort alphabetically by category, Z-A.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 priority-up Sort numerically by priority, high priority last.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 priority-down Sort numerically by priority, high priority first.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 The different possibilities will be tried in sequence, and testing stops
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 if one comparison returns a \"not-equal\". For example, the default
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 '(time-up category-keep priority-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 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
550 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
551 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
552 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
553 the sequence given in `org-agenda-files'. Within each category sort by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 priority.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 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
557 categories by priority."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (const time-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (const time-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (const category-keep)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (const category-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (const category-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (const priority-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (const priority-down))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (defcustom org-sort-agenda-notime-is-late t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 "Non-nil means, items without time are considered late.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 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
572 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
573 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
574 :group 'org-agenda
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (defvar org-category nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 "Variable used by org files to set a category for agenda display.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 Such files should use a file variable to set it, for example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 -*- mode: org; org-category: \"ELisp\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 If the file does not specify a category, the file's base name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 is used instead.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (defgroup org-structure nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 "Options concerning structure editing in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 :tag "Org Structure"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
591 (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
592 "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
593 The function(s) in this hook must accept a single argument which indicates
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
594 the new state that was set by the most recent `org-cycle' command. The
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
595 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
596 `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
597 the values `folded', `children', or `subtree'."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
598 :group 'org-structure
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
599 :type 'hook)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
600
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
601 (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
602 "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
603 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
604 as possible."
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
605 :group 'org-structure
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
606 :type 'hook)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
607
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (defcustom org-adapt-indentation t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 "Non-nil means, adapt indentation when promoting and demoting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 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
611 indentation is increased by one space in a demotion command, and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 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
613 body starts at column 0, indentation is not changed at all."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 :group 'org-structure
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (defcustom org-cycle-emulate-tab t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 "Where should `org-cycle' emulate TAB.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 nil Never
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 white Only in completely white lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 t Everywhere except in headlines"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 :group 'org-structure
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 :type '(choice (const :tag "Never" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (const :tag "Only in completely white lines" white)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (const :tag "Everywhere except in headlines" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (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
629 "Formats for `format-time-string' which are used for time stamps.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 It is not recommended to change this constant.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
632 (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
633 "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
634 When doing an `org-occur' it is useful to show the headline which
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
635 follows the match, even if they do not match the regexp. This makes it
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
636 easier to edit directly inside the sparse tree. However, if you use
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
637 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
638 unnecessary clutter."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
639 :group 'org-structure
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
640 :type 'boolean)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
641
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
642
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (defgroup org-link nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 "Options concerning links in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 :tag "Org Link"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (defcustom org-allow-space-in-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 "Non-nil means, file names in links may contain space characters.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 When nil, it becomes possible to put several links into a line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (defcustom org-line-numbers-in-file-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 "Non-nil means, file links from `org-store-link' contain line numbers.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 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
657 by the command `org-open-at-point'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 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
659 negates this setting for the duration of the command."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (defcustom org-keep-stored-link-after-insertion nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 "Non-nil means, keep link in list for entire session.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 The command `org-store-link' adds a link pointing to the current
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 location to an internal list. These links accumulate during a session.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 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
669 Org-mode file (offering completion for all stored links). When this
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 option is nil, every link which has been inserted once using `C-c C-l'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 will be removed from the list, to make completing the unused links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 more efficient."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (defcustom org-link-frame-setup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 '((vm . vm-visit-folder-other-frame)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (gnus . gnus-other-frame)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (file . find-file-other-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 "Setup the frame configuration for following links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 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
682 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
683 set this up for the different types of links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 For VM, use any of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 vm-visit-folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 vm-visit-folder-other-frame
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 For Gnus, use any of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 gnus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 gnus-other-frame
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 For FILE, use any of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 find-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 find-file-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 find-file-other-frame
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 For the calendar, use the variable `calendar-setup'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 For BBDB, it is currently only possible to display the matches in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 another window."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 :type '(list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (cons (const vm)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (const vm-visit-folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (const vm-visit-folder-other-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (const vm-visit-folder-other-frame)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (cons (const gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (const gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (const gnus-other-frame)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (cons (const file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (const find-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (const find-file-other-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (const find-file-other-frame)))))
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 (defcustom org-usenet-links-prefer-google nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 "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
716 When nil, Gnus will be used for such links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 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
718 negates this setting for the duration of the command."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (defcustom org-open-non-existing-files nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 "Non-nil means, `org-open-file' will open non-existing file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 When nil, an error will be generated."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (defcustom org-confirm-shell-links t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 "Non-nil means, ask for confirmation before executing shell links.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 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
731 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (defconst org-file-apps-defaults-linux
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 '((t . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 ("jpg" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 ("gif" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 ("ppm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 ("pgm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 ("pbm" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 ("tif" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 ("png" . "xv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 ("ps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 ("ps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 ("eps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 ("eps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 ("dvi" . "xdvi %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 ("mpeg" . "plaympeg %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 ("mp3" . "plaympeg %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 ("fig" . "xfig %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 ("pdf" . "acroread %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 ("doc" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 ("ppt" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 ("pps" . "soffice %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 ("html" . "netscape -remote openURL(%s,new-window)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 ("htm" . "netscape -remote openURL(%s,new-window)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 ("xs" . "soffice %s"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 "Default file applications on a UNIX/LINUX system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (defconst org-file-apps-defaults-macosx
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 '((t . "open %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 ("ps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 ("ps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 ("eps" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 ("eps.gz" . "gv %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 ("dvi" . "xdvi %s")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 ("fig" . "xfig %s"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 "Default file applications on a MacOS X system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 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
771 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
772 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (defconst org-file-apps-defaults-windowsnt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 '((t . (w32-shell-execute "open" file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 "Default file applications on a Windows NT system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 The system \"open\" is used for most files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 See `org-file-apps'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (defcustom org-file-apps
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 ("txt" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 ("tex" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 ("ltx" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 ("org" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 ("el" . emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 "External applications for opening `file:path' items in a document.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 Org-mode uses system defaults for different file types, but
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 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
791 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
792 and the corresponding command. Possible values for the command are:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 `emacs' The file will be visited by the current Emacs process.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 `default' Use the default application for this file type.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 string A command to be executed by a shell. %s will be replaced
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 by the path to the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 sexp A lisp form which will be evaluated. The file path will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 be available in the lisp variable `file'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 For more examples, see the system specific constants
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 `org-file-apps-defaults-macosx'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 `org-file-apps-defaults-windowsnt'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 `org-file-apps-defaults-linux'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 :group 'org-link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (cons (string :tag "Extension")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (choice :value ""
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (const :tag "Visit with Emacs" 'emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 (const :tag "Use system default" 'default)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (string :tag "Command")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (sexp :tag "Lisp form")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (defgroup org-remember nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 "Options concerning interaction with remember.el."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 :tag "Org Remember"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (defcustom org-directory "~/org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 "Directory with org files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 This directory will be used as default to prompt for org files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 Used by the hooks for remember.el."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 :type 'directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (defcustom org-default-notes-file "~/.notes"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 "Default target for storing notes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 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
828 the value of `remember-data-file'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (const :tag "Default from remember-data-file" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (defcustom org-reverse-note-order nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 "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
836 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
837 :group 'org-remember
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 (const :tag "Reverse always" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 (const :tag "Reverse never" nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 (repeat :tag "By file name regexp"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 (cons regexp boolean))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 (defgroup org-table nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 "Options concerning tables in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 :tag "Org Table"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
849 (defcustom org-enable-table-editor 'optimized
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 "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
851 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
852
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
853 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
854 do the following
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
855 - 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
856 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
857 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
858 - 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
859 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
860 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
861 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
862 `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
863 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
864 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
865 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
866
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
867 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
868 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
869
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
870 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
871 but in order to toggle optimization, a restart is required."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 :group 'org-table
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
873 :type '(choice
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
874 (const :tag "off" nil)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
875 (const :tag "on" t)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
876 (const :tag "on, optimized" optimized)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (defcustom org-table-default-size "5x2"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 "The default size for newly created tables, Columns x Rows."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 :group 'org-table
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
881 :type 'string)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (defcustom org-table-automatic-realign t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 "Non-nil means, automatically re-align table when pressing TAB or RETURN.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 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
886 removal/insertion."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (defcustom org-table-spaces-around-separators '(1 . 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 "The number of spaces to be placed before and after separators."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\"")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (defcustom org-table-spaces-around-invisible-separators '(1 . 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 "The number of spaces to be placed before and after separators.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 This option applies when the column separators have been made invisible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\"")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 (defcustom org-table-number-regexp "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*$"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 "Regular expression for recognizing numbers in table columns.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 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
904 right. If not, it will be aligned to the left.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 The default value of this option is a regular expression which allows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 anything which looks remotely like a number as used in scientific
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 context. For example, all of the following will be considered a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 number:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 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
911
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 Other options offered by the customize interface are more restrictive."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 :type '(choice
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 (const :tag "Positive Integers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 "^[0-9]+$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 (const :tag "Integers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 "^[-+]?[0-9]+$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (const :tag "Floating Point Numbers"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.[0-9]*\\)$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (const :tag "Floating Point Number or Integer"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 (const :tag "Exponential, Floating point, Integer"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 "^[-+]?[0-9.]+\\([eEdD][-+0-9]+\\)?$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (const :tag "Very General Number-Like"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 (string :tag "Regexp:")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (defcustom org-table-number-fraction 0.5
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 "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
931 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
932 fraction of fields is matched by `org-table-number-fraction',
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 alignment to the right border applies."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (defcustom org-export-highlight-first-table-line t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 "Non-nil means, highlight the first table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 In HTML export, this means use <th> instead of <td>.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 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
941 In Org-mode tables, all lines before the first horizontal separator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 line will be formatted with <th> tags."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
946 (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
947 "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
948 :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
949 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
950
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (defcustom org-table-tab-recognizes-table.el t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 "Non-nil means, TAB will automatically notice a table.el table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 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
954 calls `table-recognize-table'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (defcustom org-export-prefer-native-exporter-for-tables nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 "Non-nil means, always export tables created with table.el natively.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 Natively means, use the HTML code generator in table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 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
962 the table does not use row- or column-spanning). This has the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 advantage, that the automatic HTML conversions for math symbols and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 sub/superscripts can be applied. Org-mode's HTML generator is also
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 much faster."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (defcustom org-enable-fixed-width-editor t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 "Non-nil means, lines starting with \":\" are treated as fixed-width.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 This currently only means, they are never auto-wrapped.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 When nil, such lines will be treated like ordinary lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 :group 'org-table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (defgroup org-export nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 "Options for exporting org-listings."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 :tag "Org Export"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (defcustom org-export-language-setup
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 '(("en" "Author" "Date" "Table of Contents")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 ("da" "Ophavsmand" "Dato" "Indhold")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 ("de" "Autor" "Datum" "Inhaltsverzeichnis")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 ("es" "Autor" "Fecha" "\xccndice")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 ("fr" "Auteur" "Date" "Table des Mati\xe8res")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 ("it" "Autore" "Data" "Indice")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 ("nl" "Auteur" "Datum" "Inhoudsopgave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 "Terms used in export text, translated to different languages.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 Use the variable `org-export-default-language' to set the language,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 or use the +OPTION lines for a per-file setting."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 :type '(repeat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 (string :tag "HTML language tag")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 (string :tag "Author")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (string :tag "Date")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 (string :tag "Table of Contents"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 (defcustom org-export-default-language "en"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 "The default language of HTML export, as a string.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 This should have an association in `org-export-language-setup'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (defcustom org-export-headline-levels 3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 "The last level which is still exported as a headline.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 Inferior levels will produce itemize lists when exported.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 Note that a numeric prefix argument to an exporter function overrides
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 this setting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 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
1015 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 :type 'number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (defcustom org-export-with-section-numbers t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 "Non-nil means, add section numbers to headlines when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 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
1022 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 (defcustom org-export-with-toc t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 "Non-nil means, create a table of contents in exported files.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 The TOC contains headlines with levels up to`org-export-headline-levels'.
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 Headlines which contain any TODO items will be marked with \"(*)\" in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 ASCII export, and with red color in HTML output.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 In HTML output, the TOC will be clickable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 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
1035 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 (defcustom org-export-preserve-breaks nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 "Non-nil means, preserve all line breaks when exporting.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 Normally, in HTML output paragraphs will be reformatted. In ASCII
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 export, line breaks will always be preserved, regardless of this variable.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 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
1044 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 (defcustom org-export-html-inline-images t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 "Non-nil means, inline images into exported HTML pages.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 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
1050 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
1051 you will have to move the image and maybe change the link."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (defcustom org-export-html-expand t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 "Non-nil means, for HTML export, treat @<...> as HTML tag.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 When nil, these tags will be exported as plain text and therefore
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 not be interpreted by a browser.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 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
1061 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 (defcustom org-export-with-fixed-width t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 "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
1066 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
1067 example
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 : ;; Some Lisp examples
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 : (while (defc cnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 : (ding))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 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
1072 has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 (defcustom org-export-with-tables t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 "Non-nil means, lines starting with \"|\" define a table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 For example:
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 | Name | Address | Birthday |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 |-------------+----------+-----------|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 | Arthur Dent | England | 29.2.2100 |
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 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 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
1089 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 (defcustom org-export-html-table-tag
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 "<table border=1 cellspacing=0 cellpadding=6>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 "The HTML tag used to start a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 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
1096 borders and spacing."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 :type 'string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 (defcustom org-export-with-emphasize t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1101 "Non-nil means, interpret *word*, /word/, and _word_ as emphasized text.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 If the export target supports emphasizing text, the word will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 typeset in bold, italic, or underlined, respectively. Works only for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 single words, but you can say: I *really* *mean* *this*.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 In ASCII export, this option has no effect.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 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
1108 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 (defcustom org-match-sexp-depth 3
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 "Number of stacked braces for sub/superscript matching.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 This has to be set before loading org.el to be effective."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 :type 'integer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 ;; FIXME: Should () parens be removed as well in sub/superscripts?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 (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
1119 "Non-nil means, interpret \"_\" and \"^\" for export.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 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
1121 superscripts. Several characters after \"_\" or \"^\" will be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 considered as a single item - so grouping with {} is normally not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 needed. For example, the following things will be parsed as single
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 sub- or superscripts.
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 10^24 or 10^tau several digits will be considered 1 item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 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
1128 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
1129 terminated by almost any nonword/nondigit char.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 x_{i^2} or x^(2-i) braces or parenthesis do grouping.
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 Still, ambiguity is possible - so when in doubt use {} to enclose the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 sub/superscript.
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-with-TeX-macros t
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1141 "Non-nil means, interpret simple TeX-like macros when exporting.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 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
1144 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
1145 names in HTML export, see the constant `org-html-entities'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 In ASCII export, this option has no effect.
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 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
1149 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (defcustom org-export-html-with-timestamp nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 "Non-nil means, write `org-export-html-html-helper-timestamp'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 into the exported html text. Otherwise, the buffer will just be saved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 to a file."
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-export-html-html-helper-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 "<br><br><hr><p><!-- hhmts start --> <!-- hhmts end -->\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
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 'string)
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 (defcustom org-export-ascii-show-new-buffer t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 "Non-nil means, popup buffer containing the exported ASCII text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 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
1168 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 (defcustom org-export-html-show-new-buffer nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 "Non-nil means, popup buffer containing the exported html text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 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
1174 :group 'org-export
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 :type 'boolean)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 (defgroup org-faces nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 "Faces for highlighting in Org-mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 :tag "Org Faces"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 :group 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 (defface org-level-1-face ;; font-lock-function-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 "Face used for level 1 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 (defface org-level-2-face ;; font-lock-variable-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 '((((type tty) (class color)) (:foreground "yellow" :weight light))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (((class color) (background light)) (:foreground "DarkGoldenrod"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 (((class color) (background dark)) (:foreground "LightGoldenrod"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 "Face used for level 2 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 (defface org-level-3-face ;; font-lock-keyword-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 (((class color) (background light)) (:foreground "Purple"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 (((class color) (background dark)) (:foreground "Cyan"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 "Face used for level 3 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 :group 'org-faces)
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 (defface org-level-4-face ;; font-lock-comment-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 '((((type tty pc) (class color) (background light)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 (((class color) (background light)) (:foreground "Firebrick"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 (((class color) (background dark)) (:foreground "chocolate1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 "Face used for level 4 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 (defface org-level-5-face ;; font-lock-type-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (((class color) (background light)) (:foreground "ForestGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 (((class color) (background dark)) (:foreground "PaleGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 "Face used for level 5 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (defface org-level-6-face ;; font-lock-constant-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 '((((type tty) (class color)) (:foreground "magenta"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 (((class color) (background light)) (:foreground "CadetBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 (((class color) (background dark)) (:foreground "Aquamarine"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 "Face used for level 6 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (defface org-level-7-face ;; font-lock-builtin-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 '((((type tty) (class color)) (:foreground "blue" :weight light))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 (((class color) (background light)) (:foreground "Orchid"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (((class color) (background dark)) (:foreground "LightSteelBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 "Face used for level 7 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1240 (defface org-level-8-face ;; font-lock-string-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 (((class color) (background light)) (:foreground "RosyBrown"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (((class color) (background dark)) (:foreground "LightSalmon"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 (t (:italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 "Face used for level 8 headlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 (defface org-warning-face ;; font-lock-warning-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 '((((type tty) (class color)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 (((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
1251 (((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
1252 ; (((class color) (background dark)) (:foreground "Pink" :bold t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 (t (:inverse-video t :bold t)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1254 "Face for deadlines and TODO keywords."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1257 (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
1258 "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
1259 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
1260 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
1261 `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
1262 :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
1263 :type 'boolean)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1264
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1265 (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
1266 '((((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
1267 (((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
1268 (((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
1269 (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
1270 "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
1271 `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
1272 :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
1273
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1274 ;; Inheritance does not yet work for xemacs. So we just copy...
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 (defface org-deadline-announce-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 "Face for upcoming deadlines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (defface org-scheduled-today-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 (((class color) (background light)) (:foreground "DarkGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (((class color) (background dark)) (:foreground "PaleGreen"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 "Face for items scheduled for a certain day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (defface org-scheduled-previously-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 '((((type tty pc) (class color) (background light)) (:foreground "red"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 (((class color) (background light)) (:foreground "Firebrick"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (((class color) (background dark)) (:foreground "chocolate1"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (t (:bold t :italic t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 "Face for items scheduled previously, and not yet done."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 (defface org-link-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 (((class color) (background light)) (:foreground "Purple"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 (((class color) (background dark)) (:foreground "Cyan"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (t (:bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 "Face for links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (defface org-done-face ;; font-lock-type-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 '((((type tty) (class color)) (:foreground "green"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 (((class color) (background dark)) (:foreground "PaleGreen" :bold t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (t (:bold t :underline t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 "Face used for DONE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 (defface org-table-face ;; font-lock-function-name-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 '((((type tty) (class color)) (:foreground "blue" :weight bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (((class color) (background light)) (:foreground "Blue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 (((class color) (background dark)) (:foreground "LightSkyBlue"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 (t (:inverse-video t :bold t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 "Face used for tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 :group 'org-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 (defvar org-level-faces
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 '(
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 org-level-1-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 org-level-2-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 org-level-3-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 org-level-4-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 org-level-5-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 org-level-6-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 org-level-7-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 org-level-8-face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (defvar org-n-levels (length org-level-faces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 ;; Tell the compiler about dynamically scoped variables,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 ;; and variables from other packages
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (eval-when-compile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 (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
1342 (defvar original-date)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 (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
1344 (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
1345 (defvar orgtbl-mode-menu)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (defvar org-html-entities)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 (defvar org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 (defvar org-cursor-color)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (defvar org-time-was-given)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 (defvar org-ts-what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (defvar timecnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352 (defvar levels-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 (defvar title)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (defvar author)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 (defvar email)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (defvar text)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (defvar entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 (defvar date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 (defvar language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 (defvar options)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 (defvar ans1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 (defvar ans2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (defvar starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 (defvar include-all-loc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 (defvar vm-message-pointer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 (defvar vm-folder-directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 (defvar wl-summary-buffer-elmo-folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (defvar wl-summary-buffer-folder-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (defvar gnus-group-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 (defvar gnus-article-current)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 (defvar w3m-current-url)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 (defvar org-selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (defvar calendar-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 (defvar remember-save-after-remembering)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (defvar remember-data-file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 ;;; Define the mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (defvar org-mode-map (copy-keymap outline-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 "Keymap for Org-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 (defvar org-struct-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 (defvar org-org-menu)
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 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (defun org-mode (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 "Outline-based notes management and organizer, alias
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 \"Carstens outline-mode for keeping track of everything.\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 Org-mode develops organizational tasks around a NOTES file which
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 contains information about projects as plain text. Org-mode is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 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
1394 of large files well structured. It supports ToDo items, deadlines and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 time stamps, which magically appear in the diary listing of the Emacs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 calendar. Tables are easily created with a built-in table editor.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 Plain text URL-like links connect to websites, emails (VM), Usenet
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 messages (Gnus), BBDB entries, and any files related to the project.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 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
1400 can be exported as a well-structured ASCII or HTML file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1402 The following commands are available:
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 \\{org-mode-map}"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 (outline-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 (setq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 (setq mode-name "Org")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (use-local-map org-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 (easy-menu-add org-org-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 (setq outline-regexp "\\*+")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (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
1414 (org-set-regexps-and-options)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (set (make-local-variable 'font-lock-unfontify-region-function)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 'org-unfontify-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 ;; 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
1418 (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
1419 (make-local-hook 'before-change-functions) ;; needed for XEmacs
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (add-hook 'before-change-functions 'org-before-change-function nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 'local)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (set (make-local-variable 'auto-fill-inhibit-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (concat "\\*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 (if (or org-enable-table-editor org-enable-fixed-width-editor)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 "\\|[ \t]*["
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (if org-enable-table-editor "|" "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (if org-enable-fixed-width-editor ":" "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 "]"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 ;; Hook, and startup actions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 (if (or arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 (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
1434 (interactive-p)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 (= (point-min) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 (insert " -*- mode: org -*-\n\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 (run-hooks 'org-mode-hook)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1440 (unless (boundp 'org-inhibit-startup)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1441 (if org-startup-with-deadline-check
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1442 (call-interactively 'org-check-deadlines)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1443 (cond
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1444 ((eq org-startup-folded t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1445 (org-cycle))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1446 ((eq org-startup-folded 'contents)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1447 (org-cycle) (org-cycle))))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 ;;; Font-Lock stuff
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 (defvar org-mouse-map (make-sparse-keymap))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (define-key org-mouse-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 (define-key org-mouse-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 (require 'font-lock)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 (defconst org-link-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 (if org-allow-space-in-links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^\t\n\r]+[^ \t\n\r]\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ \t\n\r]+\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 "Regular expression for matching links.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (defconst org-ts-lengths
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 (cons (length (format-time-string (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (length (format-time-string (cdr org-time-stamp-formats))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 "This holds the lengths of the two different time formats.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 (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
1470 "Regular expression for fast time stamp matching.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (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
1472 "Regular expression matching time strings for analysis.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 ">")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 "Regular expression matching time stamps, with groups.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 "Regular expression matching a time stamp range.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 org-ts-regexp "\\)?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 "Regular expression matching a time stamp or time stamp range.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 (defun org-activate-links (limit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 "Run through the buffer and add overlays to links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 (if (re-search-forward org-link-regexp limit t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (add-text-properties (match-beginning 0) (match-end 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (list 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 'keymap org-mouse-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 (defun org-activate-dates (limit)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1491 "Run through the buffer and add overlays to dates."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 (if (re-search-forward org-tsr-regexp limit t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 (add-text-properties (match-beginning 0) (match-end 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 (list 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 'keymap org-mouse-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (defun org-font-lock-level ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (defun org-set-font-lock-defaults ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 (let ((org-font-lock-extra-keywords
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 (list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 '(org-activate-links (0 'org-link-face))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 '(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
1510 (list (concat "^\\*+[ \t]*" org-not-done-regexp)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1511 '(1 'org-warning-face t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (list (concat "\\[#[A-Z]\\]") '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (list (concat "\\<" org-deadline-string) '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (list (concat "\\<" org-scheduled-string) '(0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 ;; (3 'bold))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 ;; (3 'italic))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 ;; (3 'underline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 '("\\<FIXME\\>" (0 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 '(1 'org-warning-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 '("^#.*" (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
1525 (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
1526 (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
1527 '(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
1528 (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
1529 '(1 'org-done-face t)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (1 'org-table-face t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 '("^[ \t]*\\(:.*\\)" (1 'org-table-face t)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (set (make-local-variable 'org-font-lock-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (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
1536 ; on XEmacs if noutline is ever ported
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 '((eval . (list "^\\(\\*+\\).*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 0 '(nth
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 (% (- (match-end 1) (match-beginning 1) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 org-n-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 org-level-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 nil t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 '(("^\\(\\(\\*+\\)[^\r\n]*\\)[\n\r]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (1 (nth (% (- (match-end 2) (match-beginning 2) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 org-n-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 org-level-faces)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 nil t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 org-font-lock-extra-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (set (make-local-variable 'font-lock-defaults)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 '(org-font-lock-keywords t nil nil backward-paragraph))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 (kill-local-variable 'font-lock-keywords) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 (defvar org-font-lock-keywords nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 (defun org-unfontify-region (beg end &optional maybe_loudly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 "Remove fontification and activation overlays from links."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (font-lock-default-unfontify-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (let* ((modified (buffer-modified-p)) ;; FIXME: Why did I add this???
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 (buffer-undo-list t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 (inhibit-read-only t) (inhibit-point-motion-hooks t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 (inhibit-modification-hooks t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 deactivate-mark buffer-file-name buffer-file-truename)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 (remove-text-properties beg end '(mouse-face nil keymap nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 ;;; Visibility cycling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 (defvar org-cycle-global-status nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (defvar org-cycle-subtree-status nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (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
1570 "Visibility cycling for Org-mode.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 - When this function is called with a prefix argument, rotate the entire
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 buffer through 3 states (global cycling)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 1. OVERVIEW: Show only top-level headlines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 2. CONTENTS: Show all headlines of all levels, but no body text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 3. SHOW ALL: Show everything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 - 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
1579 by this line through 3 different states (local cycling)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 1. FOLDED: Only the main headline is shown.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 2. CHILDREN: The main headline and the direct children are shown. From
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 this state, you can move to one of the children and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 zoom in further.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 3. SUBTREE: Show the entire subtree, including body text.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1586 - 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
1587 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
1588
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 - When point is not at the beginning of a headline, execute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 `indent-relative', like TAB normally does. See the option
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 `org-cycle-emulate-tab' for details.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 - 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
1594 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
1595 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1597 (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
1598 (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
1599 ;; special case: use global cycling
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (setq arg t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 ((org-at-table-p 'any)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 ;; Enter the table or move to the next field in the table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 (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
1607 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1608 (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
1609 (org-table-next-field))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1611 ((eq arg t) ;; Global cycling
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 (eq org-cycle-global-status 'overview))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 ;; We just created the overview - now do table of contents
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 ;; This can be slow in very large buffers, so indicate action
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 (message "CONTENTS...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 ;; Visit all headings and show their offspring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623 (while (and (progn (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 (outline-previous-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 (error (goto-char (point-min))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 (show-branches)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 (if (bobp) (throw 'exit nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 (message "CONTENTS...done"))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1631 (setq org-cycle-global-status 'contents)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1632 (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
1633
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 (eq org-cycle-global-status 'contents))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 ;; We just showed the table of contents - now show everything
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 (show-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 (message "SHOW ALL")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1639 (setq org-cycle-global-status 'all)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1640 (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
1641
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643 ;; Default action: go to overview
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1644 (hide-sublevels 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 (message "OVERVIEW")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1646 (setq org-cycle-global-status 'overview)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1647 (run-hook-with-args 'org-cycle-hook 'overview))))
58792
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 ((integerp arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1650 ;; 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
1651 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1652 (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
1653 (outline-up-heading arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1654 (show-subtree)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
1655
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656 ((save-excursion (beginning-of-line 1) (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 ;; At a heading: rotate between three different views
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1658 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659 (let ((goal-column 0) beg eoh eol eos nxh)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660 ;; First, some boundaries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 (org-back-to-heading) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 (while (and (not (eobp)) ;; this is like `next-line'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 (get-char-property (1- (point)) 'invisible))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 (beginning-of-line 2)) (setq eol (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 (outline-end-of-heading) (setq eoh (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (outline-end-of-subtree) (setq eos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 (outline-next-heading) (setq nxh (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 ;; Find out what to do next and set `this-command'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 ((= eos eoh)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 ;; Nothing is hidden behind this heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 (message "EMPTY ENTRY")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 (setq org-cycle-subtree-status nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 ((>= eol eos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 ;; Entire subtree is hidden in one line: open it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (show-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (show-children)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 (message "CHILDREN")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1682 (setq org-cycle-subtree-status 'children)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1683 (run-hook-with-args 'org-cycle-hook 'children))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 ((and (eq last-command this-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (eq org-cycle-subtree-status 'children))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 ;; We just showed the children, now show everything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687 (show-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 (message "SUBTREE")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1689 (setq org-cycle-subtree-status 'subtree)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1690 (run-hook-with-args 'org-cycle-hook 'subtree))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 ;; Default action: hide the subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 (hide-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694 (message "FOLDED")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1695 (setq org-cycle-subtree-status 'folded)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1696 (run-hook-with-args 'org-cycle-hook 'folded)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 ;; TAB emulation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 (buffer-read-only (org-back-to-heading))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 ((if (and (eq org-cycle-emulate-tab 'white)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (save-excursion (beginning-of-line 1) (looking-at "[ \t]+$")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 (eq org-cycle-emulate-tab t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 (if (and (looking-at "[ \n\r\t]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 (string-match "^[ \t]*$" (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 (point-at-bol) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (and (looking-at "[ \t]+") (replace-match ""))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 (indent-relative))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 (t (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 (org-cycle)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1716 (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
1717 "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
1718 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
1719 (cond
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1720 ((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
1721 ((eq state 'content) nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1722 ((eq state 'all) nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1723 ((eq state 'folded) nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1724 ((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
1725 ((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
1726
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1727 (defun org-subtree-end-visible-p ()
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1728 "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
1729 (pos-visible-in-window-p
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1730 (save-excursion (outline-end-of-subtree) (point))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1731
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1732 (defun org-first-headline-recenter (&optional N)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1733 "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
1734 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
1735 (goto-char (point-min))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1736 (re-search-forward (concat "^" outline-regexp))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1737 (beginning-of-line)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1738 (recenter (prefix-numeric-value N)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1739
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 (defvar org-goto-window-configuration nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 (defvar org-goto-marker nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 (defvar org-goto-map (make-sparse-keymap))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 (let ((cmds '(isearch-forward isearch-backward)) cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 (while (setq cmd (pop cmds))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 (substitute-key-definition cmd cmd org-goto-map global-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 (define-key org-goto-map [(return)] 'org-goto-ret)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1747 (define-key org-goto-map [(left)] 'org-goto-left)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1748 (define-key org-goto-map [(right)] 'org-goto-right)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 (define-key org-goto-map [(?q)] 'org-goto-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750 (define-key org-goto-map [(control ?g)] 'org-goto-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 (define-key org-goto-map [(tab)] 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 (define-key org-goto-map [(down)] 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 (define-key org-goto-map [(up)] 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 (define-key org-goto-map "n" 'outline-next-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 (define-key org-goto-map "p" 'outline-previous-visible-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (define-key org-goto-map "f" 'outline-forward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (define-key org-goto-map "b" 'outline-backward-same-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 (define-key org-goto-map "u" 'outline-up-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 (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
1760 (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
1761 (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
1762 (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
1763 (define-key org-goto-map "\C-c\C-u" 'outline-up-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 (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
1766
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 (defconst org-goto-help
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 "Select a location to jump to, press RET
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 \[Up]/[Down]=next/prev headline TAB=cycle visibility RET=select [Q]uit")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (defun org-goto ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 "Go to a different location of the document, keeping current visibility.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 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
1775 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
1776 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
1777 which may not be what you want.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 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
1780 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
1781 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
1782 original buffer in which the visibility is still unchanged. It then jumps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 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
1784 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785 (let* ((org-goto-start-pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 (selected-point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 (org-get-location (current-buffer) org-goto-help)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 (if selected-point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (goto-char selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 (if (org-invisible-p) (org-show-hierarchy-above)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 (error "Quit"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 (defun org-get-location (buf help)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 "Let the user select a location in the Org-mode buffer BUF.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 This function uses a recursive edit. It returns the selected position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 or nil."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 (let (org-selected-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 (switch-to-buffer (get-buffer-create "*org-goto*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (with-output-to-temp-buffer "*Help*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 (princ help))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 (insert-buffer buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (let ((org-startup-truncated t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810 (org-startup-folded t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 (org-startup-with-deadline-check nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 (org-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 (setq buffer-read-only t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 (if (boundp 'org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815 (goto-char org-goto-start-pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (goto-char (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 (org-beginning-of-line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 (message "Select location and press RET")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 ;; now we make sure that during selection, ony very few keys work
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 ;; and that it is impossible to switch to another window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 (let ((gm (current-global-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 (overriding-local-map org-goto-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 (use-global-map org-goto-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 (recursive-edit))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (use-global-map gm)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (kill-buffer "*org-goto*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 org-selected-point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 ;; 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
1832 (defun org-goto-ret (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 current-prefix-arg arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 (defun org-goto-left (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 (if (org-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 current-prefix-arg (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 (error "Not on a heading")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 (defun org-goto-right (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 "Finish org-goto by going to the new location."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (if (org-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 (outline-end-of-subtree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856 (or (eobp) (forward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 (setq org-selected-point (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 current-prefix-arg (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1860 (error "Not on a heading")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1861
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1862 (defun org-goto-quit ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1863 "Finish org-goto without cursor motion."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1864 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1865 (setq org-selected-point nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1866 (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1867
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 ;;; Promotion, Demotion, Inserting new headlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1869
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 (defvar org-ignore-region nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1871 "To temporarily disable the active region.")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1872
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1873 (defun org-insert-heading (&optional arg)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874 "Insert a new heading with same depth at point."
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
1875 (interactive "P")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876 (let* ((head (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1877 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 (error (outline-next-heading)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1880 (prog1 (match-string 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 (funcall outline-level)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882 (unless (bolp) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 (insert head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884 (unless (eolp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (save-excursion (newline-and-indent)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1886 (unless (equal (char-before) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887 (insert " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888 (run-hooks 'org-insert-heading-hook)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1890 (defun org-insert-todo-heading (arg)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1891 "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
1892 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
1893 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
1894 (interactive "P")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1895 (org-insert-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1896 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1897 (org-back-to-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1898 (outline-previous-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1899 (looking-at org-todo-line-regexp))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1900 (if (or arg
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1901 (not (match-beginning 2))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1902 (equal (match-string 2) org-done-string))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1903 (insert (car org-todo-keywords) " ")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1904 (insert (match-string 2) " ")))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
1905
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 (defun org-promote-subtree (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 "Promote the entire subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 See also `org-promote'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 (org-map-tree 'org-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 (defun org-demote-subtree (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 "Demote the entire subtree. See `org-demote'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 See also `org-promote'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 (org-map-tree 'org-demote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 (defun org-do-promote (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 "Promote the current heading higher up the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 If the region is active in transient-mark-mode, promote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 (org-map-region 'org-promote (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 (org-promote)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 (org-fix-position-after-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 (defun org-do-demote (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930 "Demote the current heading lower down the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 If the region is active in transient-mark-mode, demote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 (org-map-region 'org-demote (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 (org-demote)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938 (org-fix-position-after-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 (defun org-fix-position-after-promote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 "Make sure that after pro/demotion cursor position is right."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 (and (equal (char-after) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 (equal (char-before) ?*)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944 (forward-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 (defun org-promote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 "Promote the current heading higher up the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 If the region is active in transient-mark-mode, promote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (let* ((level (save-match-data (funcall outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 (up-head (make-string (1- level) ?*)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 (replace-match up-head nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956 (org-fixup-indentation "^ " "" "^ ?\\S-"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1957
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 (defun org-demote ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 "Demote the current heading lower down the tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 If the region is active in transient-mark-mode, demote all headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 in the region."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 (let* ((level (save-match-data (funcall outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 (down-head (make-string (1+ level) ?*)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 (replace-match down-head nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 (org-fixup-indentation "^ " " " "^\\S-"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 (defun org-map-tree (fun)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 "Call FUN for every heading underneath the current one."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 (let ((level (outline-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1973 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974 (funcall fun)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975 (while (and (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 (> (funcall outline-level) level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 (not (eobp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979 (funcall fun)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 (defun org-map-region (fun beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1982 "Call FUN for every heading between BEG and END."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 (let ((org-ignore-region t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1985 (setq end (copy-marker end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 ;; (if (fboundp 'deactivate-mark) (deactivate-mark))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 ;; (if (fboundp 'zmacs-deactivate-region) (zmacs-deactivate-region))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 (if (and (re-search-forward (concat "^" outline-regexp) nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 (funcall fun))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 (while (and (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1994 (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 (not (eobp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996 (funcall fun)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1997
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1998 (defun org-fixup-indentation (from to prohibit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 "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
2000 However, if the regexp PROHIBIT matches at all, don't do anything.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 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
2002 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
2003 is changed at all."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 (let ((end (save-excursion (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 (point-marker))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 (unless (save-excursion (re-search-forward prohibit end t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2008 (while (re-search-forward from end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009 (replace-match to)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010 (beginning-of-line 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (move-marker end nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2013 ;;; Vertical tree motion, cutting and pasting of subtrees
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2015 (defun org-move-subtree-up (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 "Move the current subtree up past ARG headlines of the same level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018 (org-move-subtree-down (- (prefix-numeric-value arg))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020 (defun org-move-subtree-down (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 "Move the current subtree down past ARG headlines of the same level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 (setq arg (prefix-numeric-value arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024 (let ((movfunc (if (> arg 0) 'outline-get-next-sibling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2025 'outline-get-last-sibling))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 (ins-point (make-marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2027 (cnt (abs arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 beg end txt folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 ;; Select the tree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 (save-excursion (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 (setq folded (org-invisible-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 (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
2036 (outline-next-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 ;; Find insertion point, with error handling
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040 (while (> cnt 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 (or (and (funcall movfunc) (looking-at outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 (progn (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2043 (error "Cannot move past superior level or buffer limit")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044 (setq cnt (1- cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 (if (> arg 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 ;; Moving forward - still need to move over subtree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2047 (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
2048 (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
2049 (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
2050 (bolp)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
2051 (newline))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052 (move-marker ins-point (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053 (setq txt (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2056 (goto-char ins-point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 (if folded (hide-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2058 (move-marker ins-point nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 (defvar org-subtree-clip ""
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2061 "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
2062 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
2063 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
2064
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2065 (defvar org-subtree-clip-folded nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2066 "Was the last copied subtree folded?
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2067 This is used to fold the tree back after pasting.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2068
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 (defun org-cut-subtree (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 "Cut the current subtree into the clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 This is a short-hand for marking the subtree and then cutting it."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2073 (org-copy-subtree arg 'cut))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2074
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 (defun org-copy-subtree (&optional arg cut)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2076 "Cut the current subtree into the clipboard.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2077 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
2078 If CUT is non nil, actually cut the subtree."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2079 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 (let (beg end folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2083 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2084 (save-excursion (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2085 (setq folded (org-invisible-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2086 (outline-end-of-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2087 (if (equal (char-after) ?\n) (forward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2088 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2089 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2090 (when (> end beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 (setq org-subtree-clip-folded folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 (if cut (kill-region beg end) (copy-region-as-kill beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2093 (setq org-subtree-clip (current-kill 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2094 (message "%s: Subtree with %d characters"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095 (if cut "Cut" "Copied")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2096 (length org-subtree-clip)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2097
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2098 (defun org-paste-subtree (&optional level tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 "Paste the clipboard as a subtree, with modification of headline level.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 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
2101 level. By default, the new level is derived from the visible headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 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
2103 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
2104 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
2105 This makes sure that the subtree remains an independent subtree and does
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 not swallow low level entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 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
2109 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
2110 cursor is after \"*****\", then the tree will be shifted to level 5.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 If you want to insert the tree as is, just use \\[yank].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2113
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 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
2115 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 (unless (org-kill-is-subtree-p tree)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118 (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119 "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
2120 (let* ((txt (or tree (current-kill 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (^re (concat "^\\(" outline-regexp "\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 (re (concat "\\(" outline-regexp "\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (^re_ (concat "\\(" outline-regexp "\\)[ \t]*"))
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 (old-level (if (string-match ^re txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127 -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2128 (force-level (cond (level (prefix-numeric-value level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2129 ((string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 ^re_ (buffer-substring (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131 (- (match-end 0) (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 (t nil)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2133 (previous-level (save-excursion
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134 (outline-previous-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 (if (looking-at re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2137 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2138 (next-level (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2139 (outline-next-visible-heading 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 (if (looking-at re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 (- (match-end 0) (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 1)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2143 (new-level (or force-level (max previous-level next-level)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 (shift (if (or (= old-level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (= new-level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 (= old-level new-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2147 0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 (- new-level old-level)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 (shift1 shift)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (delta (if (> shift 0) -1 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 (func (if (> shift 0) 'org-demote 'org-promote))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 ;; Remove the forces level indicator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (if force-level
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 (delete-region (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 ;; Make sure we start at the beginning of an empty line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2157 (if (not (bolp)) (insert "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 (if (not (looking-at "[ \t]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159 (progn (insert "\n") (backward-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 ;; Paste
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 ;; Shift if necessary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2166 (if (= shift 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 (message "Pasted at level %d, without shift" new-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2168 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 (narrow-to-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170 (while (not (= shift 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2171 (org-map-region func (point-min) (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2172 (setq shift (+ delta shift)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2173 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174 (message "Pasted at level %d, with shift by %d levels"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175 new-level shift1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 (if (and (eq org-subtree-clip (current-kill 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177 org-subtree-clip-folded)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178 ;; The tree was folded before it was killed/copied
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 (hide-subtree))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181 (defun org-kill-is-subtree-p (&optional txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 "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
2183 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
2184 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
2185 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
2186 which is OK for `org-paste-subtree'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187 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
2188 (let* ((kill (or txt (current-kill 0) ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 (start-level (and (string-match (concat "\\`" outline-regexp) kill)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 (re (concat "^" outline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 (start 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 (if (not start-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 nil ;; does not even start with a heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 (while (setq start (string-match re kill (1+ start)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 (if (< (- (match-end 0) (match-beginning 0)) start-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 (throw 'exit nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199 t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 ;;; Completion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 (defun org-complete (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 "Perform completion on word at point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 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
2206 `org-todo-keywords'.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2207 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
2208 that are supported for HTML support.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2209 If the current word is preceded by \"#+\", completes special words for
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 setting file options.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 At all other locations, this simply calls `ispell-complete-word'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2212 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2213 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2214 (let* ((end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 (beg (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 (if (equal (char-before (point)) ?\ ) (backward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2217 (skip-chars-backward "a-zA-Z0-9_:")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 (texp (equal (char-before beg) ?\\))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 "#+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 (pattern (buffer-substring-no-properties beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 (completion-ignore-case opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225 (type nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 (table (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (opt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 (setq type :opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 (mapcar (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2231 (cons (match-string 2 x) (match-string 1 x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2232 (org-split-string (org-get-current-options) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233 (texp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 (setq type :tex)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 org-html-entities)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 ((string-match "\\`\\*+[ \t]*\\'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237 (buffer-substring (point-at-bol) beg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238 (setq type :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2239 (mapcar 'list org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 (t (progn (ispell-complete-word arg) (throw 'exit nil)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241 (completion (try-completion pattern table)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2242 (cond ((eq completion t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2243 (if (equal type :opt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 (insert (substring (cdr (assoc (upcase pattern) table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 (length pattern)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246 ((null completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2247 (message "Can't find completion for \"%s\"" pattern)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2248 (ding))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249 ((not (string= pattern completion))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (if (string-match " +$" completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 (setq completion (replace-match "" t t completion)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 (insert completion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 (if (get-buffer-window "*Completions*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 (delete-window (get-buffer-window "*Completions*")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (if (and (eq type :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 (assoc completion table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 (insert " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 (if (and (equal type :opt) (assoc completion table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 "Press \\[org-complete] again to insert example settings"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 (message "Making completion list...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 (let ((list (sort (all-completions pattern table) 'string<)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 (with-output-to-temp-buffer "*Completions*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (display-completion-list list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (message "Making completion list...%s" "done"))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 ;;; Comments, TODO and DEADLINE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 (defun org-toggle-comment ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 "Change the COMMENT state of an entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 (if (looking-at (concat outline-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 "\\( +\\<" org-comment-string "\\>\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (replace-match "" t t nil 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (if (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281 (goto-char (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282 (insert " " org-comment-string))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2284 (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
2285 "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
2286 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
2287 this is nil.")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2288
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 (defun org-todo (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 "Change the TODO state of an item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 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
2292 like
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 *** TODO Write paper
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 *** DONE Call mom
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 The different keywords are specified in the variable `org-todo-keywords'. By
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 default the available states are \"TODO\" and \"DONE\".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 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
2299 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
2300 DONE are present, add TODO at the beginning of the heading.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302 With prefix arg, use completion to determined the new state. With numeric
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 prefix arg, switch to that state."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 (if (looking-at outline-regexp) (goto-char (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (or (looking-at (concat " +" org-todo-regexp " *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 (looking-at " *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 (let* ((this (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 (completion-ignore-case t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 (member (member this org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2313 (tail (cdr member))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2314 (state (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2315 ((equal arg '(4))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 ;; Read a state with completion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 (completing-read "State: " (mapcar (lambda(x) (list x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 org-todo-keywords)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320 (arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321 ;; user requests a specific state
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322 (nth (1- (prefix-numeric-value arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 ((null member) (car org-todo-keywords))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 ((null tail) nil) ;; -> first entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326 ((eq org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2327 (car tail))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2328 ((memq org-todo-interpretation '(type priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 (if (eq this-command last-command)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 (car tail)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (if (> (length tail) 0) org-done-string nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 (t nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333 (next (if state (concat " " state " ") " ")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 (replace-match next t t)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2335 (setq org-last-todo-state-is-todo
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2336 (not (equal state org-done-string)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 (run-hooks 'org-after-todo-state-change-hook)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 ;; Fixup cursor location if close to the keyword
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339 (if (and (outline-on-heading-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 (not (bolp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2341 (save-excursion (goto-char (point-at-bol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 (looking-at org-todo-line-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (< (point) (+ 2 (or (match-end 2) (match-end 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 (goto-char (or (match-end 2) (match-end 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 (just-one-space))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348 (defun org-show-todo-tree (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2349 "Make a compact tree which shows all headlines marked with TODO.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350 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
2351 headlines above the match."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 (let ((case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 (kwd-re (if arg org-todo-regexp org-not-done-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 (message "%d TODO entries found"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 (org-occur (concat "^" outline-regexp " +" kwd-re )))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358 (defun org-deadline ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 "Insert the DEADLINE: string to make a deadline.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360 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
2361 to modify it to the correct date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364 org-deadline-string " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 (format-time-string (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 (org-read-date nil 'to-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 "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
2369
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 (defun org-schedule ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 "Insert the SCHEDULED: string to schedule a TODO item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 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
2373 to modify it to the correct date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 org-scheduled-string " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377 (format-time-string (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 (org-read-date nil 'to-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 "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
2381
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2382
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 (defun org-occur (regexp &optional callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 "Make a compact tree which shows all matches of REGEXP.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385 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
2386 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
2387 to make sure editing the matching entry is easy.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388 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
2389 that the match should indeed be shown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2390 (interactive "sRegexp: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2391 (setq regexp (org-check-occur-regexp regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2392 (let ((cnt 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2393 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2394 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 (hide-sublevels 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2397 (when (or (not callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2398 (funcall callback))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2399 (setq cnt (1+ cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2400 (org-show-hierarchy-above))))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2401 (run-hooks 'org-occur-hook)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 (if (interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 (message "%d match(es) for regexp %s" cnt regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2404 cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2406 (defun org-show-hierarchy-above ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 "Make sure point and the headings hierarchy above is visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 (if (org-on-heading-p t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 (org-flag-heading nil) ; only show the heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 (org-show-hidden-entry)) ; show entire entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411 (save-excursion
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2412 (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
2413 (outline-next-heading)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 (save-excursion ; show all higher headings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416 (while (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (progn (org-up-heading-all 1) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418 (error nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 (org-flag-heading nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2420
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2421 ;;; Priorities
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 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z]\\)\\] ?\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 "Regular expression matching the priority indicator.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2426 (defvar org-remove-priority-next-time nil)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2427
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 (defun org-priority-up ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429 "Increase the priority of the current item."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 (org-priority 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 (defun org-priority-down ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434 "Decrease the priority of the current item."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 (org-priority 'down))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438 (defun org-priority (&optional action)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2439 "Change the priority of an item by ARG.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2440 ACTION can be set, up, or down."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 (setq action (or action 'set))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 (let (current new news have remove)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446 (if (looking-at org-priority-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2447 (setq current (string-to-char (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2448 have t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 (setq current org-default-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2451 ((eq action 'set)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452 (message (format "Priority A-%c, SPC to remove: " org-lowest-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 (setq new (read-char-exclusive))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2454 (cond ((equal new ?\ ) (setq remove t))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2455 ((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
2456 (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
2457 ?A org-lowest-priority))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458 ((eq action 'up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (setq new (1- current)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 ((eq action 'down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 (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
2462 (t (error "Invalid action")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 (setq new (min (max ?A (upcase new)) org-lowest-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 (setq news (format "%c" new))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 (if have
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466 (if remove
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 (replace-match "" t t nil 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 (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
2469 (if remove
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2470 (error "No priority cookie found in line")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2471 (looking-at org-todo-line-regexp)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2472 (if (match-end 2)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2473 (progn
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2474 (goto-char (match-end 2))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2475 (insert " [#" news "]"))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2476 (goto-char (match-beginning 3))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2477 (insert "[#" news "] ")))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 (if remove
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 (message "Priority removed")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 (message "Priority of current item set to %s" news))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 (defun org-get-priority (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 "Find priority cookie and return priority."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 (if (not (string-match org-priority-regexp s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487 (* 1000 (- org-lowest-priority org-default-priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (* 1000 (- org-lowest-priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 (string-to-char (match-string 2 s)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 ;;; Timestamps
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 (defvar org-last-changed-timestamp nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 (defun org-time-stamp (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 "Prompt for a date/time and insert a time stamp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 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
2498 with a prefix argument, the time stamp will contain date and time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 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
2500 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
2501 So if you press just return without typing anything, the time stamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 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
2503 at the cursor, it will be modified."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 (let ((fmt (if arg (cdr org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (org-time-was-given nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 ((and (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (eq last-command 'org-time-stamp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (eq this-command 'org-time-stamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 (insert "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 (insert (format-time-string fmt time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 ((org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2519 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521 (and (org-at-timestamp-p) (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2522 (setq org-last-changed-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523 (format-time-string fmt time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 (message "Timestamp updated"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 (setq time (let ((this-command this-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 (org-read-date arg 'totime)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2529 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 (insert (format-time-string fmt time))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 ;;; FIXME: Make the function take "Fri" as "next friday"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 (defun org-read-date (&optional with-time to-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2534 "Read a date and make things smooth for the user.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 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
2536 which will at least partially be understood by `parse-time-string'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 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
2538 hour and minute. For example,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539 3-2-5 --> 2003-02-05
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 feb 15 --> currentyear-02-15
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2541 sep 12 9 --> 2009-09-12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2542 12:45 --> today 12:45
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 22 sept 0:34 --> currentyear-09-22 0:34
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 12 --> currentyear-currentmonth-12
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 etc.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 The function understands only English month and weekday abbreviations,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547 but this can be configured with the variables `parse-time-months' and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 `parse-time-weekdays'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 While prompting, a calendar is popped up - you can also select the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 date with the mouse (button 1). The calendar shows a period of three
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 month. To scroll it to other months, use the keys `>' and `<'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 If you don't like the calendar, turn it off with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 \(setq org-popup-calendar-for-date-prompt nil).
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 With optional argument TO-TIME, the date will immediately be converted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 to an internal time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 With an optional argument WITH-TIME, the prompt will suggest to also
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559 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
2560 enter a time, and this function will inform the calling routine about
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 this change. The calling routine may then choose to change the format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 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
2563 (let* ((default-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 ;; Default time is either today, or, when entering a range,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 ;; the range start.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2568 (concat org-ts-regexp "--\\=")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 (- (point) 20) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (apply
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2571 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2572 (mapcar (lambda(x) (or x 0)) ;; FIXME: Problem with timezone?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573 (parse-time-string (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 (timestr (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576 (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
2577 (prompt (format "YYYY-MM-DD [%s]: " timestr))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 ans ans1 ans2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 second minute hour day month year tl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 (if org-popup-calendar-for-date-prompt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 ;; Also show a calendar for date selection
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 ;; Copied (with modifications) from planner.el by John Wiegley
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (calendar-forward-day (- (time-to-days default-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 (calendar-absolute-from-gregorian
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 (calendar-current-date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2590 (let* ((old-map (current-local-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 (map (copy-keymap calendar-mode-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592 (minibuffer-local-map (copy-keymap minibuffer-local-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (define-key map (kbd "RET") 'org-calendar-select)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 (define-key map (if org-xemacs-p [button1] [mouse-1])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 'org-calendar-select)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 (define-key minibuffer-local-map [(meta shift left)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 (org-eval-in-calendar '(calendar-backward-month 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599 (define-key minibuffer-local-map [(meta shift right)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 (org-eval-in-calendar '(calendar-forward-month 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2602 (define-key minibuffer-local-map [(shift up)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2603 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 (org-eval-in-calendar '(calendar-backward-week 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 (define-key minibuffer-local-map [(shift down)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 (org-eval-in-calendar '(calendar-forward-week 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 (define-key minibuffer-local-map [(shift left)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 (org-eval-in-calendar '(calendar-backward-day 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 (define-key minibuffer-local-map [(shift right)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 (org-eval-in-calendar '(calendar-forward-day 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 (define-key minibuffer-local-map ">"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 (org-eval-in-calendar '(scroll-calendar-left 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 (define-key minibuffer-local-map "<"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 (lambda () (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 (org-eval-in-calendar '(scroll-calendar-right 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 (use-local-map map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 (setq ans (read-string prompt "" nil nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 (setq ans (or ans1 ans2 ans)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2625 (use-local-map old-map)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2626 ;; Naked prompt only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 (setq ans (read-string prompt "" nil timestr)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2628
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 (if (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 "^ *\\(\\([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
2631 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 (setq year (if (match-end 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (string-to-number (match-string 2 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 (string-to-number (format-time-string "%Y")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2635 month (string-to-number (match-string 3 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 day (string-to-number (match-string 4 ans)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 (if (< year 100) (setq year (+ 2000 year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (setq ans (replace-match (format "%04d-%02d-%02d" year month day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 t t ans))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 (setq tl (parse-time-string ans)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 year (or (nth 5 tl) (string-to-number (format-time-string "%Y")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 month (or (nth 4 tl) (string-to-number (format-time-string "%m")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 day (or (nth 3 tl) (string-to-number (format-time-string "%d")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 hour (or (nth 2 tl) (string-to-number (format-time-string "%H")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645 minute (or (nth 1 tl) (string-to-number (format-time-string "%M")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 second (or (nth 0 tl) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 (if (and (boundp 'org-time-was-given)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648 (nth 2 tl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649 (setq org-time-was-given t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (if (< year 100) (setq year (+ 2000 year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (if to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652 (encode-time second minute hour day month year)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (if (or (nth 1 tl) (nth 2 tl))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 (format "%04d-%02d-%02d %02d:%02d" year month day hour minute)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2655 (format "%04d-%02d-%02d" year month day)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (defun org-eval-in-calendar (form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 "Eval FORM in the calendar window and return to current window.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 Also, store the cursor date in variable ans2."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 (let ((sw (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 (select-window (get-buffer-window "*Calendar*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662 (eval form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (when (calendar-cursor-to-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2664 (let* ((date (calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2665 (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
2666 (setq ans2 (format-time-string "%Y-%m-%d" time))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2667 (select-window sw)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2668
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669 (defun org-calendar-select ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 "Return to `org-read-date' with the date currently selected.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 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
2672 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2673 (when (calendar-cursor-to-date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674 (let* ((date (calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 (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
2676 (setq ans1 (format-time-string "%Y-%m-%d" time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 (if (active-minibuffer-window) (exit-minibuffer))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 (defun org-check-deadlines (ndays)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 "Check if there are any deadlines due or past due.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681 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
2682 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
2683 it is not shown. The prefix arg NDAYS can be used to test that many
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2684 days. If the prefix is a raw C-u prefix, all deadlines are shown."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2685 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2686 (let* ((org-warn-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2687 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2688 ((equal ndays '(4)) 100000)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2689 (ndays (prefix-numeric-value ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2690 (t org-deadline-warning-days)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2691 (case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693 (callback
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2694 (lambda ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695 (and (let ((d1 (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2696 (d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 (org-time-string-to-time (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 (< (- d2 d1) org-warn-days))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699 (not (org-entry-is-done-p))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700 (message "%d deadlines past-due or due within %d days"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701 (org-occur regexp callback)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 org-warn-days)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2703
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 (defun org-evaluate-time-range (&optional to-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 "Evaluate a time range by computing the difference between start and end.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 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
2707 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
2708 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
2709 next column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2710 For time difference computation, a year is assumed to be exactly 365
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 days in order to avoid rounding problems."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2712 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2713 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2714 (unless (org-at-date-range-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2715 (goto-char (point-at-bol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2716 (re-search-forward org-tr-regexp (point-at-eol) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2717 (if (not (org-at-date-range-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2718 (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
2719 (let* ((ts1 (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2720 (ts2 (match-string 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2721 (match-end (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722 (time1 (org-time-string-to-time ts1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 (time2 (org-time-string-to-time ts2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2724 (t1 (time-to-seconds time1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2725 (t2 (time-to-seconds time2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2726 (diff (abs (- t2 t1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2727 (negative (< (- t2 t1) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2728 (ys (floor (* 365 24 60 60)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2729 (ds (* 24 60 60))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2730 (hs (* 60 60))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2731 (fy "%dy %dd %02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2732 (fd "%dd %02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2733 (fh "%02d:%02d")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2734 y d h m align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 (setq y (floor (/ diff ys)) diff (mod diff ys)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 d (floor (/ diff ds)) diff (mod diff ds)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2737 h (floor (/ diff hs)) diff (mod diff hs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2738 m (floor (/ diff 60)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2739 (if (not to-buffer)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2740 (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
2741 (when (org-at-table-p)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2742 (goto-char match-end)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2743 (setq align t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2744 (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
2745 (if (looking-at
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2746 "\\( *-? *[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
2747 (replace-match ""))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2748 (if negative (insert " -"))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2749 (if (> y 0) (insert " " (format fy y d h m))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2750 (if (> d 0) (insert " " (format fd d h m))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2751 (insert " " (format fh h m))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2752 (if align (org-table-align))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2753 (message "Time difference inserted"))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2755 (defun org-make-tdiff-string (y d h m)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 (let ((fmt "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2757 (l nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 (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
2759 l (push y l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 (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
2761 l (push d l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2762 (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
2763 l (push h l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2764 (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
2765 l (push m l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 (apply 'format fmt (nreverse l))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2768 (defun org-time-string-to-time (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 (apply 'encode-time (org-parse-time-string s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 (defun org-parse-time-string (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2772 "Parse the standard Org-mode time string.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2773 This should be a lot faster than the normal parse-time-string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2774 (if (string-match org-ts-regexp1 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775 (list 0
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2776 (string-to-number (or (match-string 8 s) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2777 (string-to-number (or (match-string 7 s) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778 (string-to-number (match-string 4 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779 (string-to-number (match-string 3 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 (string-to-number (match-string 2 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 nil nil nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 (make-list 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784 (defun org-timestamp-up (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 "Increase the date item at the cursor by one.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2786 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
2787 the day, change that.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 With prefix ARG, change by that many units."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790 (org-timestamp-change (prefix-numeric-value arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 (defun org-timestamp-down (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 "Decrease the date item at the cursor by one.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2794 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
2795 the day, change that.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2796 With prefix ARG, change by that many units."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2798 (org-timestamp-change (- (prefix-numeric-value arg))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2799
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2800 (defun org-timestamp-up-day (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2801 "Increase the date in the time stamp by one day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 With prefix ARG, change that many days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2803 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2804 (org-timestamp-change (prefix-numeric-value arg) 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 (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
2807 "Decrease the date in the time stamp by one day.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2808 With prefix ARG, change that many days."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2810 (org-timestamp-change (- (prefix-numeric-value arg)) 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2811
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2812 (defsubst org-pos-in-match-range (pos n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2813 (and (match-beginning n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2814 (<= (match-beginning n) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2815 (>= (match-end n) pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2816
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2817 (defun org-at-timestamp-p ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2818 "Determine if the cursor is or at a timestamp."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2819 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2820 (let* ((tsr org-ts-regexp2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2821 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 (ans (or (looking-at tsr)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2823 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2824 (skip-chars-backward "^<\n\r\t")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2825 (if (> (point) 1) (backward-char 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2826 (and (looking-at tsr)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2827 (> (- (match-end 0) pos) -1))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2828 (and (boundp 'org-ts-what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2829 (setq org-ts-what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2830 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831 ((org-pos-in-match-range pos 2) 'year)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2832 ((org-pos-in-match-range pos 3) 'month)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2833 ((org-pos-in-match-range pos 7) 'hour)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2834 ((org-pos-in-match-range pos 8) 'minute)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2835 ((or (org-pos-in-match-range pos 4)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836 (org-pos-in-match-range pos 5)) 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837 (t 'day))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 ans))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840 (defun org-timestamp-change (n &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2841 "Change the date in the time stamp at point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 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
2843 `year', `minute', `second'. If WHAT is not given, the cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 in the timestamp determines what will be changed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (let ((fmt (car org-time-stamp-formats))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 org-ts-what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 ts time time0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2849 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2850 (error "Not at a timestamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2851 (setq org-ts-what (or what org-ts-what))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852 (setq fmt (if (<= (abs (- (cdr org-ts-lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853 (- (match-end 0) (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2854 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 (cdr org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 (car org-time-stamp-formats)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 (setq ts (match-string 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 (replace-match "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 (setq time0 (org-parse-time-string ts))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860 (setq time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 (apply 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 (list (or (car time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 (list (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 (list (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 (list (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 (list (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 (list (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 (nthcdr 6 time0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 (if (eq what 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2871 (let ((cal-date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 (set-buffer "*Calendar*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2875 (calendar-cursor-to-date)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2876 (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2877 (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2878 (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 (setcar time0 (or (car time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 (setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 (setcar (nthcdr 2 time0) (or (nth 1 time0) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 (setq time (apply 'encode-time time0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 (insert (setq org-last-changed-timestamp (format-time-string fmt time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885 ;; Try to recenter the calendar window, if any
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 (if (and org-calendar-follow-timestamp-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 (get-buffer-window "*Calendar*" t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 (memq org-ts-what '(day month year)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 (org-recenter-calendar (time-to-days time)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 (defun org-recenter-calendar (date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 "If the calendar is visible, recenter it to DATE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 (let* ((win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2894 (cwin (get-buffer-window "*Calendar*" t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2895 (when cwin
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 (select-window cwin)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897 (calendar-goto-date (if (listp date) date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 (calendar-gregorian-from-absolute date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2899 (select-window win))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2901 (defun org-goto-calendar (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 "Go to the Emacs calendar at the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 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
2904 A prefix ARG can be used force the current date."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 (let ((tsr org-ts-regexp) diff)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907 (if (or (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 (looking-at (concat ".*" tsr))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2911 (let ((d1 (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912 (d2 (time-to-days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913 (org-time-string-to-time (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914 (setq diff (- d2 d1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915 (calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916 (calendar-goto-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 (if (and diff (not arg)) (calendar-forward-day diff))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2918
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919 (defun org-date-from-calendar ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 "Insert time stamp corresponding to cursor date in *Calendar* buffer.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 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
2922 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 (org-timestamp-change 0 'calendar))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 ;;; Agenda, and Diary Integration
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927 ;;; Define the mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 (defvar org-agenda-mode-map (make-sparse-keymap)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 "Keymap for org-agenda-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (defvar org-agenda-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933 (defvar org-agenda-follow-mode nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 (defvar org-agenda-buffer-name "*Org Agenda*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 (defvar org-agenda-redo-command nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2938 (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
2939 "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
2940
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2941 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
2942
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
2943 \\{org-agenda-mode-map}"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 (kill-all-local-variables)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 (setq major-mode 'org-agenda-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947 (setq mode-name "Org-Agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948 (use-local-map org-agenda-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 (easy-menu-add org-agenda-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 (if org-startup-truncated (setq truncate-lines t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 (setq org-agenda-follow-mode nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 '("Agenda") "Agenda Files"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 (list
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2957 ["Edit File List" (customize-variable 'org-agenda-files) t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 (mapcar 'org-file-menu-entry org-agenda-files)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 (run-hooks 'org-agenda-mode-hook))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 (define-key org-agenda-mode-map [(tab)] 'org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964 (define-key org-agenda-mode-map [(return)] 'org-agenda-switch-to)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2965 (define-key org-agenda-mode-map " " 'org-agenda-show)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966 (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
2967 (define-key org-agenda-mode-map "o" 'delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2968 (define-key org-agenda-mode-map "l" 'org-agenda-recenter)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (define-key org-agenda-mode-map "t" 'org-agenda-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970 (define-key org-agenda-mode-map "." 'org-agenda-goto-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 (define-key org-agenda-mode-map "w" 'org-agenda-week-view)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 (define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2975 (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 (while l (define-key org-agenda-mode-map
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (int-to-string (pop l)) 'digit-argument)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 (define-key org-agenda-mode-map "f" 'org-agenda-follow-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 (define-key org-agenda-mode-map "d" 'org-agenda-toggle-diary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 (define-key org-agenda-mode-map "r" 'org-agenda-redo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2983 (define-key org-agenda-mode-map "q" 'org-agenda-quit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 (define-key org-agenda-mode-map "x" 'org-agenda-exit)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985 (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
2986 (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
2987 (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
2988 (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
2989 (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
2990 (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
2991 (define-key org-agenda-mode-map "\C-c," 'org-agenda-priority)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 (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
2993 (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
2994 (eval-after-load "calendar"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
2995 '(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
2996 '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
2997 (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
2998 (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
2999 (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
3000 (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
3001 (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
3002 (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
3003 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3005 (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
3006 (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
3007 (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
3008 (define-key org-agenda-mode-map [(right)] 'org-agenda-later)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3009 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3010
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3011 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3012 "Local keymap for agenda entries from Org-mode.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3013
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 (define-key org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3015 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 (define-key org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3018
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3019 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020 '("Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 ("Agenda Files")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3023 ["Show" org-agenda-show t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3024 ["Go To (other window)" org-agenda-goto t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 ["Go To (one window)" org-agenda-switch-to t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 ["Follow Mode" org-agenda-follow-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027 :style toggle :selected org-agenda-follow-mode :active t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3028 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3029 ["Cycle TODO" org-agenda-todo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3030 ("Reschedule"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3031 ["Reschedule +1 day" org-agenda-date-later t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3032 ["Reschedule -1 day" org-agenda-date-earlier t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3033 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3034 ["Reschedule to ..." org-agenda-date-prompt t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3035 ("Priority"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3036 ["Set Priority" org-agenda-priority t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3037 ["Increase Priority" org-agenda-priority-up t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3038 ["Decrease Priority" org-agenda-priority-down t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3039 ["Show Priority" org-agenda-show-priority t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3040 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3041 ["Rebuild" org-agenda-redo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3042 ["Goto Today" org-agenda-goto-today t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3043 ["Next Dates" org-agenda-later (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3044 ["Previous Dates" org-agenda-earlier (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3045 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3046 ["Week/Day View" org-agenda-week-view (local-variable-p 'starting-day)]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3047 ["Include Diary" org-agenda-toggle-diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3048 :style toggle :selected org-agenda-include-diary :active t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3049 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3050 ["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
3051 ("Calendar Commands"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3052 ["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
3053 ["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
3054 ["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
3055 ["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
3056 ["Convert" org-agenda-convert-date t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 ["Quit" org-agenda-quit t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 ["Exit and Release Buffers" org-agenda-exit t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 (defvar org-agenda-markers nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3063 "List of all currently active markers created by org-agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 (defvar org-agenda-last-marker-time (time-to-seconds (current-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3065 "Creation time of the last agenda marker.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3066
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3067 (defun org-agenda-new-marker (&optional pos)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3068 "Return a new agenda marker.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 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
3070 no longer in use."
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3071 (let ((m (copy-marker (or pos (point)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3072 (setq org-agenda-last-marker-time (time-to-seconds (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3073 (push m org-agenda-markers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3074 m))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3075
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3076 (defun org-agenda-maybe-reset-markers (&optional force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3077 "Reset markers created by org-agenda. But only if they are old enough."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3078 (if (or force
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3079 (> (- (time-to-seconds (current-time))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3080 org-agenda-last-marker-time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3081 5))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (while org-agenda-markers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3083 (move-marker (pop org-agenda-markers) nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3084
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3085 (defvar org-agenda-new-buffers nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086 "Buffers created to visit agenda files.")
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 (defun org-get-agenda-file-buffer (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3089 "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
3090 it to the list of buffers which might be released later."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 (let ((buf (find-buffer-visiting file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3092 (if buf
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 buf ; just return it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 ;; Make a new buffer and remember it
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095 (setq buf (find-file-noselect file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 (if buf (push buf org-agenda-new-buffers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 buf)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099 (defun org-release-buffers (blist)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100 "Release all buffers in list, asking the user for confirmation when needed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 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
3102 \(if the user agrees) and then killed."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103 (let (buf file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 (while (setq buf (pop blist))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3105 (setq file (buffer-file-name buf))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3106 (when (and (buffer-modified-p buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 (y-or-n-p (format "Save file %s? " file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3110 (set-buffer buf) (save-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3111 (kill-buffer buf))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3113 (defun org-timeline (&optional include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 "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
3115 Only entries with a time stamp of today or later will be listed. With
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3116 one C-u prefix argument, past entries will also be listed.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 With two C-u prefixes, all unfinished TODO items will also be shown,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3118 under the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3119 If the buffer contains an active region, only check the region for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 dates."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3121 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3122 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3123 (org-agenda-maybe-reset-markers 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3124 (let* ((dopast include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125 (dotodo (equal include-all '(16)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126 (entry (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3127 (org-agenda-files (list (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 (date (calendar-current-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3129 (win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3130 (pos1 (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3131 (beg (if (org-region-active-p) (region-beginning) (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3132 (end (if (org-region-active-p) (region-end) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3133 (day-numbers (org-get-all-dates beg end 'no-ranges
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3134 t)) ; always include today
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135 (today (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136 (org-respect-restriction t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 (past t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3138 s e rtn d pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3139 (setq org-agenda-redo-command
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3140 (list 'progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3141 (list 'switch-to-buffer-other-window (current-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3142 (list 'org-timeline include-all)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 (if (not dopast)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144 ;; Remove past dates from the list of dates.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3145 (setq day-numbers (delq nil (mapcar (lambda(x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146 (if (>= x today) x nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 day-numbers))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3148 (switch-to-buffer-other-window
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 (get-buffer-create org-agenda-buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3152 (org-agenda-mode) (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3153 (while (setq d (pop day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3154 (if (and (>= d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3155 dopast
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3156 past)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3157 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3158 (setq past nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3159 (insert (make-string 79 ?-) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3160 (setq date (calendar-gregorian-from-absolute d))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3161 (setq s (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3162 (if dotodo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3163 (setq rtn (org-agenda-get-day-entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3164 entry date :todo :timestamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3165 (setq rtn (org-agenda-get-day-entries entry date :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3166 (if (or rtn (equal d today))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3168 (insert (calendar-day-name date) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 (number-to-string (extract-calendar-day date)) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170 (calendar-month-name (extract-calendar-month date)) " "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 (number-to-string (extract-calendar-year date)) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172 (put-text-property s (1- (point)) 'face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 'org-link-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174 (if (equal d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3175 (put-text-property s (1- (point)) 'org-today t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3176 (insert (org-finalize-agenda-entries rtn) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3177 (put-text-property s (1- (point)) 'day d))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179 (setq buffer-read-only t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3180 (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
3181 (point-min)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 (when (not org-select-timeline-window)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 (select-window win)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3184 (goto-char pos1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3185
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3186 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3187 (defun org-agenda (&optional include-all start-day ndays)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3188 "Produce a weekly view from all files in variable `org-agenda-files'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189 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
3190 will be able to go to other weeks.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3191 With one C-u prefix argument INCLUDE-ALL, all unfinished TODO items will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3192 also be shown, under the current date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 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
3194 given in `org-agenda-start-on-weekday'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 NDAYS defaults to `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (org-agenda-maybe-reset-markers 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 (require 'calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 (let* ((org-agenda-start-on-weekday
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 (if (or (equal ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 (and (null ndays) (equal 1 org-agenda-ndays)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 nil org-agenda-start-on-weekday))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 (files (copy-sequence org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 (win (selected-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (today (time-to-days (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 (sd (or start-day today))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207 (start (if (or (null org-agenda-start-on-weekday)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (< org-agenda-ndays 7))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3209 sd
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3210 (let* ((nt (calendar-day-of-week
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211 (calendar-gregorian-from-absolute sd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 (n1 org-agenda-start-on-weekday)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3213 (d (- nt n1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 (- sd (+ (if (< d 0) 7 0) d)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215 (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
3216 s e rtn rtnall file date d start-pos end-pos)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217 (setq org-agenda-redo-command
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3218 (list 'org-agenda include-all start-day ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 ;; Make the list of days
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3220 (setq ndays (or ndays org-agenda-ndays))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 (while (> ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222 (push (1+ (car day-numbers)) day-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223 (setq ndays (1- ndays)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 (setq day-numbers (nreverse day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 (if (not (equal (current-buffer) (get-buffer org-agenda-buffer-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227 (delete-other-windows)
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 (set (make-local-variable 'starting-day) (car day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 (set (make-local-variable 'include-all-loc) include-all)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 (when (and (or include-all org-agenda-include-all-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 (member today day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 (setq files org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 rtnall nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (catch 'nextfile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241 (org-check-agenda-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242 (setq date (calendar-gregorian-from-absolute today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 rtn (org-agenda-get-day-entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 file date :todo))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246 (if rtnall (insert (org-finalize-agenda-entries rtnall) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (while (setq d (pop day-numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 (setq date (calendar-gregorian-from-absolute d)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 s (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (if (or (= d today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251 (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
3252 (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
3253 (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
3254 (setq end-pos (point))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 (setq files org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 rtnall nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258 (catch 'nextfile
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259 (org-check-agenda-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260 (setq rtn (org-agenda-get-day-entries file date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3262 (if org-agenda-include-diary
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3263 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3264 (require 'diary-lib)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3265 (setq rtn (org-get-entries-from-diary date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 (setq rtnall (append rtnall rtn))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3267 (if (or rtnall org-agenda-show-all-dates)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3268 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 (insert (format "%-9s %2d %-9s %4d\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 (calendar-day-name date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3271 (extract-calendar-day date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3272 (calendar-month-name (extract-calendar-month date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 (extract-calendar-year date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274 (put-text-property s (1- (point)) 'face
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3275 'org-link-face)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 (if rtnall (insert (org-finalize-agenda-entries rtnall) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 (put-text-property s (1- (point)) 'day d))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3278 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279 (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
3280 (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
3281 (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
3282 (/ (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
3283 (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
3284 (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
3285 (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
3286 (recenter -1)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3287 (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
3288 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3289 (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
3290 (recenter 1))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3291 (goto-char (or start-pos 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3292 (if (not org-select-agenda-window) (select-window win))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3293 (message "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3294
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3295 (defun org-check-agenda-file (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3296 "Make sure FILE exists. If not, ask user what to do."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3297 ;; 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
3298 ;; Could probably be fixed by explicitly going to the buffer.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3299 (when (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3300 (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
3301 file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302 (let ((r (downcase (read-char-exclusive))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 ((equal r ?r)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 (org-remove-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 (throw 'nextfile t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 (t (error "Abort"))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3308
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309 (defun org-agenda-quit (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 "Exit agenda by removing the window or the buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 (let ((buf (current-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313 (if (not (one-window-p)) (delete-window))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314 (kill-buffer buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 (org-agenda-maybe-reset-markers 'force)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3316
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3317 (defun org-agenda-exit (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318 "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
3319 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
3320 Org-mode buffers visited directly by the user will not be touched."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3321 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3322 (org-release-buffers org-agenda-new-buffers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3323 (setq org-agenda-new-buffers nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3324 (org-agenda-quit arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3325
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 (defun org-agenda-redo (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3327 "Rebuild Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329 (eval org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3330
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 (defun org-agenda-goto-today (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 "Go to today."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3334 (if (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3335 (let ((cmd (car org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336 (iall (nth 1 org-agenda-redo-command))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3337 (nday (nth 3 org-agenda-redo-command)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3338 (eval (list cmd iall nil nday)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (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
3340 (point-min)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342 (defun org-agenda-later (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343 "Go forward in time by `org-agenda-ndays' days.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344 With prefix ARG, go forward that many times `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3346 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3347 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 (+ starting-day (* arg org-agenda-ndays))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (defun org-agenda-earlier (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3352 "Go back in time by `org-agenda-ndays' days.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 With prefix ARG, go back that many times `org-agenda-ndays'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3358 (- starting-day (* arg org-agenda-ndays))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 (defun org-agenda-day-view (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3361 "Switch agenda to single day view."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3362 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3363 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3364 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 (setq org-agenda-ndays 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 (org-agenda include-all-loc starting-day 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 (defun org-agenda-week-view (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3369 "Switch agenda to week view."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3370 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3371 (unless (boundp 'starting-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (error "Not allowed"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (setq org-agenda-ndays
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374 (if (equal org-agenda-ndays 1) 7 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375 (org-agenda include-all-loc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3376 (or (get-text-property (point) 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3377 starting-day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3378 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379 (message "Switched to %s view"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380 (if (equal org-agenda-ndays 1) "day" "week")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3381
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3382 (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
3383 "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
3384 (interactive "p")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3385 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3386 (if (looking-at "^\\S-") (forward-char 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3387 (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
3388 (progn
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3389 (backward-char 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3390 (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
3391 (goto-char (match-beginning 0)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3392
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3393 (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
3394 "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
3395 (interactive "p")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3396 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3397 (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
3398 (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
3399
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3400 (defun org-agenda-follow-mode ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 "Toggle follow mode in an agenda buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (setq org-agenda-follow-mode (not org-agenda-follow-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3404 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3405 (message "Follow mode is %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406 (if org-agenda-follow-mode "on" "off")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3408 (defun org-agenda-toggle-diary ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409 "Toggle follow mode in an agenda buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3410 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3411 (setq org-agenda-include-diary (not org-agenda-include-diary))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3412 (org-agenda-redo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 (org-agenda-set-mode-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3414 (message "Diary inclusion turned %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3415 (if org-agenda-include-diary "on" "off")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3416
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3417 (defun org-agenda-set-mode-name ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3418 "Set the mode name to indicate all the small mode settings."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3419 (setq mode-name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3420 (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
3421 (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
3422 (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
3423 (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
3424 (if org-agenda-include-diary " Diary" "")))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 (force-mode-line-update))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3426
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3427 (defun org-agenda-post-command-hook ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3428 (and (eolp) (not (bolp)) (backward-char 1))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 (if (and org-agenda-follow-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 (get-text-property (point) 'org-marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431 (org-agenda-show)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (defun org-get-entries-from-diary (date)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 "Get the (emacs calendar) diary entries for DATE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 (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
3436 (diary-display-hook '(fancy-diary-display))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3437 (list-diary-entries-hook
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3438 (cons 'org-diary-default-entry list-diary-entries-hook))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 entries
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3440 (disable-org-diary t))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3442 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3443 (list-diary-entries date 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3444 (if (not (get-buffer fancy-diary-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3445 (setq entries nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 (save-excursion
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3447 (switch-to-buffer fancy-diary-buffer)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3448 (setq buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 (if (= (point-max) 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3450 ;; No entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3451 (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
3452 ;; 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
3453 (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
3454 ;; 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
3455 (goto-char (point-min))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3456 (while (and (re-search-forward "^" nil t) (not (eobp)))
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3457 (replace-match " Diary: ")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3458 (add-text-properties (point-at-bol) (point)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3459 (text-properties-at (point))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3460 (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
3461 (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
3462 (setq entries (buffer-substring (point-min) (- (point-max) 1)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3463 (set-buffer-modified-p nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464 (kill-buffer fancy-diary-buffer)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3465 (when entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 (setq entries (org-split-string entries "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467 (setq entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3468 (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3470 (if (string-match "\\<\\([012][0-9]\\):\\([0-6][0-9]\\)" x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3471 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472 1 (length x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473 (list 'time-of-day
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3474 (+ (* 100 (string-to-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3475 (match-string 1 x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3476 (string-to-number (match-string 2 x))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3477 x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3478 x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3479 entries)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3480
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3481 (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
3482 "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
3483 This gets rid of the date, the underline under the date, and
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3484 the dummy entry installed by org-mode to ensure non-empty diary for each
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3485 date."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3486 (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
3487 (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
3488 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3489 (replace-match "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3490 (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
3491 (replace-match "")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3492 (while (re-search-backward "^ +" nil t) (replace-match "")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3493 (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
3494 (delete-region (point-min) (min (point-max) (1+ (match-end 0)))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3495 (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
3496 (replace-match "")))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3497
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3498 ;; 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
3499 ;; 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
3500 ;; advice unnecessarily
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3501 (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
3502 '(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
3503 "Make the position visible."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3504 (if (and (boundp 'disable-org-diary) ;; called from org-agenda
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3505 (stringp string)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3506 (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
3507 (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
3508 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
3509 (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
3510 '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
3511 'help-echo
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3512 (format
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3513 "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
3514 (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
3515 '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
3516 '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
3517 string))))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3518
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3519 (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
3520 "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
3521 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
3522 ;; 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
3523 (condition-case nil
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3524 (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
3525 (error
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3526 (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
3527
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (defun org-add-file (&optional file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 "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
3530 These are the files which are being checked for agenda entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531 Optional argument FILE means, use this file instead of the current.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532 It is possible (but not recommended) to add this function to the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 `org-mode-hook'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536 (let* ((file (or file (buffer-file-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (if (interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538 (error "Buffer is not visiting a file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 (throw 'exit nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 (true-file (file-truename file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3541 (afile (abbreviate-file-name file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542 (present (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 (equal true-file (file-truename x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3546 (if (not present)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3548 (setq org-agenda-files
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3549 (cons afile org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 ;; Make sure custom.el does not end up with Org-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552 (customize-save-variable 'org-agenda-files org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3554 (message "Added file: %s" afile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555 (message "File was already in list: %s" afile)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3556
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557 (defun org-remove-file (&optional file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3558 "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
3559 These are the files which are being checked for agenda entries.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560 Optional argument FILE means, use this file instead of the current."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562 (let* ((file (or file (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563 (true-file (file-truename file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564 (afile (abbreviate-file-name file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 (files (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3566 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3567 (if (equal true-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568 (file-truename x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569 nil x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3570 org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3571 (if (not (= (length files) (length org-agenda-files)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3572 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573 (setq org-agenda-files files)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 (customize-save-variable 'org-agenda-files org-agenda-files)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 (org-install-agenda-files-menu)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 (message "Removed file: %s" afile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577 (message "File was not in list: %s" afile))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3579 (defun org-file-menu-entry (file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580 (vector file (list 'find-file file) t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3582 (defun org-get-all-dates (beg end &optional no-ranges force-today)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 "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
3584 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
3585 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
3586 sure that TODAY is included in the list."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 (let (dates date day day1 day2 ts1 ts2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588 (if force-today
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3589 (setq dates (list (time-to-days (current-time)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3590 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 (while (re-search-forward org-ts-regexp end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593 (setq day (time-to-days (org-time-string-to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3594 (substring (match-string 1) 0 10))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595 (or (memq day dates) (push day dates)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 (unless no-ranges
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598 (while (re-search-forward org-tr-regexp end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 (setq ts1 (substring (match-string 1) 0 10)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 ts2 (substring (match-string 2) 0 10)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 day1 (time-to-days (org-time-string-to-time ts1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 day2 (time-to-days (org-time-string-to-time ts2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603 (while (< (setq day1 (1+ day1)) day2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 (or (memq day1 dates) (push day1 dates)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 (sort dates '<))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608 (defun org-diary (&rest args)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3609 "Returns diary information from org-files.
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3610 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
3611 It accesses org files and extracts information from those files to be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3612 listed in the diary. The function accepts arguments specifying what
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3613 items should be listed. The following arguments are allowed:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 :timestamp List the headlines of items containing a date stamp or
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616 date range matching the selected date. Deadlines will
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617 also be listed, on the expiration day.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 :deadline List any deadlines past due, or due within
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 `org-deadline-warning-days'. The listing occurs only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 in the diary for *today*, not at any other date. If
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 an entry is marked DONE, it is no longer listed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 :scheduled List all items which are scheduled for the given date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 The diary for *today* also contains items which were
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 scheduled earlier and are not yet marked DONE.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628 :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
3629 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
3630 Like deadlines, these entries only show up in the
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 diary for *today*, not at any other date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 The call in the diary file should look like this:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635 &%%(org-diary) ~/path/to/some/orgfile.org
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637 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
3638 all files listed in `org-agenda-files' will be checked automatically:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 &%%(org-diary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642 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
3643 arguments (:deadline :scheduled :timestamp) are used. So the example above may
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 also be written as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3645
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 &%%(org-diary :deadline :timestamp :scheduled)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648 The function expects the lisp variables `entry' and `date' to be provided
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 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
3650 function from a program - use `org-agenda-get-day-entries' instead."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 (org-agenda-maybe-reset-markers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 (setq args (or args '(:deadline :scheduled :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 (list entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655 org-agenda-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656 file rtn results)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 ;; 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
3658 ;; the calendar. Org Agenda will list these entries itself.
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
3659 (if (boundp 'disable-org-diary) (setq files nil))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 (while (setq file (pop files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 (setq rtn (apply 'org-agenda-get-day-entries file date args))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 (concat (org-finalize-agenda-entries results) "\n")))
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-agenda-get-day-entries (file date &rest args)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666 "Does the work for `org-diary' and `org-agenda'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 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
3668 the one returned by `calendar-current-date'. ARGS are symbols indicating
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 which kind of entries should be extracted. For details about these, see
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3670 the documentation of `org-diary'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3671 (setq args (or args '(:deadline :scheduled :timestamp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3672 (let* ((org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 (org-startup-folded nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674 (buffer (if (file-exists-p file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675 ; (find-file-noselect file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 (org-get-agenda-file-buffer file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677 (error "No such file %s" file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3678 (respect-narrow-p (boundp 'org-respect-restriction))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 arg results rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680 (if (not buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 ;; 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
3682 (format "ORG-AGENDA-ERROR: No such org-file %s" file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3685 (let ((case-fold-search nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3687 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688 (if respect-narrow-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3689 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 ;; Respect a region to restrict search
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3691 (narrow-to-region (region-beginning) (region-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3692 ;; If we work for the calendar or many files,
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3693 ;; get rid of any restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3694 (widen))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3695 (while (setq arg (pop args))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3696 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3697 ((and (eq arg :todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 (equal date (calendar-current-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3699 (setq rtn (org-agenda-get-todos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3700 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3701 ((eq arg :timestamp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3702 (setq rtn (org-agenda-get-blocks))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 (setq results (append results rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704 (setq rtn (org-agenda-get-timestamps))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3705 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3706 ((eq arg :scheduled)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 (setq rtn (org-agenda-get-scheduled))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3708 (setq results (append results rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709 ((and (eq arg :deadline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 (equal date (calendar-current-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 (setq rtn (org-agenda-get-deadlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3712 (setq results (append results rtn))))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713 results))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715 (defun org-entry-is-done-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3716 "Is the current entry marked DONE?"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3718 (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
3719 (looking-at org-nl-done-regexp))))
58792
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 (defun org-at-date-range-p ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3722 "Is the cursor inside a date range?"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3723 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3724 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3725 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3726 (let ((pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3727 (skip-chars-backward "^<\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3728 (skip-chars-backward "<")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3729 (and (looking-at org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3730 (>= (match-end 0) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3731 (throw 'exit t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3732 (skip-chars-backward "^<\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3733 (skip-chars-backward "<")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3734 (and (looking-at org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3735 (>= (match-end 0) pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3736 (throw 'exit t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3737 nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3738
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 (defun org-agenda-get-todos ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 "Return the TODO information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 (let* ((props (list 'face nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3742 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3743 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3745 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3746 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 (regexp (concat "[\n\r]\\*+ *\\(" org-not-done-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3749 "[^\n\r]*\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 marker priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751 ee txt pl)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3753 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 (goto-char (match-beginning 1))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3755 (setq marker (org-agenda-new-marker (point-at-bol))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 txt (org-format-agenda-item "" (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 priority
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 (+ (org-get-priority txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 (if org-todo-kwd-priority-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 (- org-todo-kwd-max-priority -2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 (length
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 (member (match-string 2) org-todo-keywords)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 (add-text-properties
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3765 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
3766 'priority priority)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 (push txt ee)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3770 (goto-char (match-end 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773 (defconst org-agenda-no-heading-message
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3774 "No heading for this item in buffer or region")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3775
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 (defun org-agenda-get-timestamps ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3777 "Return the date stamp information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3779 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3781 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3782 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3783 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3784 (regexp (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3785 (substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3786 (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3787 (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3788 (apply 'encode-time ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3789 (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3790 0 11)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3791 marker hdmarker deadlinep scheduledp donep tmp priority
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3792 ee txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3793 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3794 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3795 (if (not (save-match-data (org-at-date-range-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3796 (progn
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3797 (setq marker (org-agenda-new-marker (match-beginning 0))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 tmp (buffer-substring (max (point-min)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799 (- (match-beginning 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3800 org-ds-keyword-length))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801 (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3802 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
3803 scheduledp (string-match org-scheduled-regexp tmp)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3804 donep (org-entry-is-done-p))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3805 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3806 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3807 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3808 (goto-char (match-end 1))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3809 (setq hdmarker (org-agenda-new-marker))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3810 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3812 (format "%s%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3813 (if deadlinep "Deadline: " "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3814 (if scheduledp "Scheduled: " ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3815 (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3816 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3817 (setq priority (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3818 (add-text-properties
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3819 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
3820 'org-hd-marker hdmarker) props)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3821 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822 (if deadlinep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3824 0 (length txt)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3825 (list 'face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3826 (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
3827 'undone-face 'org-warning-face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3828 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 'priority (+ 100 priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3831 (if scheduledp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3832 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 (list 'face 'org-scheduled-today-face
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3835 'undone-face 'org-scheduled-today-face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3836 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 priority (+ 99 priority))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3838 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 (list 'priority priority) txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3842 (push txt ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3843 (outline-next-heading))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3844 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3845
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3846 (defun org-agenda-get-deadlines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3847 "Return the deadline information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3848 (let* ((wdays org-deadline-warning-days)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3849 (props (list 'mouse-face 'highlight
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3850 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3851 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3852 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3853 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3854 (regexp org-deadline-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3855 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3856 (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
3857 d2 diff pos pos1
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3858 ee txt head hdmarker)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3859 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3860 (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
3861 (setq pos (1- (match-beginning 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3862 d2 (time-to-days
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3863 (org-time-string-to-time (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3864 diff (- d2 d1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3865 ;; When to show a deadline in the calendar:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3866 ;; If the expiration is within wdays warning time.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3867 ;; Past-due deadlines are only shown on the current date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3868 (if (and (< diff wdays) todayp (not (= diff 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3869 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3870 (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3871 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3872 (goto-char (match-end 0))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3873 (setq pos1 (match-end 1))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3874 (setq head (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3875 (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3876 (progn (skip-chars-forward "^\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3877 (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3878 (if (string-match org-looking-at-done-regexp head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3879 (setq txt nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3880 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3881 (format "In %3d d.: " diff) head))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3882 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3883 (when txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3884 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3885 0 (length txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3886 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3887 (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
3888 'org-hd-marker (org-agenda-new-marker pos1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3889 'priority (+ (- 10 diff) (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3890 '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
3891 ((<= diff 5) 'org-scheduled-previously-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3892 (t nil))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3893 'undone-face (cond
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3894 ((<= diff 0) 'org-warning-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3895 ((<= diff 5) 'org-scheduled-previously-face)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3896 (t nil))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3897 'done-face 'org-done-face)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3899 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3900 (push txt ee)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3901 ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3902
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3903 (defun org-agenda-get-scheduled ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3904 "Return the scheduled information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3905 (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
3906 'undone-face 'org-scheduled-previously-face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3907 'done-face 'org-done-face
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3908 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3909 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3910 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3911 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3912 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3913 (regexp org-scheduled-time-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3914 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3915 (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
3916 d2 diff marker hdmarker pos pos1
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3917 ee txt head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3918 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3919 (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
3920 (setq pos (1- (match-beginning 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3921 d2 (time-to-days
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3922 (org-time-string-to-time (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3923 diff (- d2 d1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3924 ;; When to show a scheduled item in the calendar:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3925 ;; If it is on or past the date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3926 (if (and (< diff 0) todayp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3927 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3928 (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3929 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3930 (goto-char (match-end 0))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3931 (setq pos1 (match-end 1))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3932 (setq head (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3933 (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3934 (progn (skip-chars-forward "^\r\n") (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3935 (if (string-match org-looking-at-done-regexp head)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3936 (setq txt nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3937 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3938 (format "Sched.%2dx: " (- 1 diff)) head))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3940 (when txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3941 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942 0 (length txt)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3943 (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
3944 'org-hd-marker (org-agenda-new-marker pos1)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3945 'priority (+ (- 5 diff) (org-get-priority txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946 props) txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947 (push txt ee)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948 ee))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (defun org-agenda-get-blocks ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951 "Return the date-range information for agenda display."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3952 (let* ((props (list 'face nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3953 'mouse-face 'highlight
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3954 'keymap org-agenda-keymap
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3955 'help-echo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956 (format "mouse-2 or RET jump to org file %s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3957 (abbreviate-file-name (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3958 (regexp org-tr-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3959 (d0 (calendar-absolute-from-gregorian date))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3960 marker hdmarker ee txt d1 d2 s1 s2)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962 (while (re-search-forward regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3963 (setq s1 (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 s2 (match-string 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965 d1 (time-to-days (org-time-string-to-time s1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 d2 (time-to-days (org-time-string-to-time s2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 (if (and (> (- d0 d1) -1) (> (- d2 d0) -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 ;; Only allow days between the limits, because the normal
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3969 ;; date stamps will catch the limits.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3970 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 (setq marker (org-agenda-new-marker (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3973 (progn
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
3974 (setq hdmarker (org-agenda-new-marker (match-end 1)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3975 (goto-char (match-end 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3976 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3977 (setq txt (org-format-agenda-item
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3978 (format "(%d/%d): "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3979 (1+ (- d0 d1)) (1+ (- d2 d1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3980 (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3981 (setq txt org-agenda-no-heading-message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3982 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3983 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
3984 'org-hd-marker hdmarker
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3985 'priority (org-get-priority txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3986 props)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3987 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3988 (push txt ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3989 (outline-next-heading))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3990 ;; Sort the entries by expiration date.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3991 (nreverse ee)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3992
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3993
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3994 (defun org-format-agenda-item (prefix txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995 "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
3996 In particular, this indents the line and adds a category."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3997 (let ((cat (or org-category
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3998 (file-name-sans-extension
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3999 (file-name-nondirectory (buffer-file-name)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4000 time rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4001 (if (symbolp cat) (setq cat (symbol-name cat)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4002 (setq rtn (format " %-10s %s%s" (concat cat ":") prefix txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4003 (add-text-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4004 0 2 (list 'category (downcase cat)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4005 'prefix-length (- (length rtn) (length txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4006 'time-of-day (org-get-time-of-day rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4007 rtn)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4008 rtn))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4009
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4010 ;; FIXME: Should this be restricted to beginning of string?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4011 (defun org-get-time-of-day (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4012 "Check string S for a time of day."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4013 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4014 (when (and
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4015 (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4016 "\\<\\([012][0-9]\\)\\(:\\([0-6][0-9]\\)\\)?\\([AaPp][Mm]\\)?\\>" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017 (or (match-beginning 2) (match-beginning 4)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4018 (+ (* 100 (+ (string-to-number (match-string 1 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4019 (if (and (match-beginning 4)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4020 (equal (downcase (match-string 4 s)) "pm"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4021 12 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4022 (if (match-beginning 3)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4023 (string-to-number (match-string 3 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4024 0)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4025
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4026 (defun org-finalize-agenda-entries (list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4027 "Sort and concatenate the agenda items."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4028 (mapconcat 'identity (sort list 'org-entries-lessp) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4029
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4030 (defsubst org-cmp-priority (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4031 "Compare the priorities of string a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4032 (let ((pa (or (get-text-property 1 'priority a) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4033 (pb (or (get-text-property 1 'priority b) 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4034 (cond ((> pa pb) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4035 ((< pa pb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4036 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4037
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4038 (defsubst org-cmp-category (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4039 "Compare the string values of categories of strings a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4040 (let ((ca (or (get-text-property 1 'category a) ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4041 (cb (or (get-text-property 1 'category b) "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4042 (cond ((string-lessp ca cb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4043 ((string-lessp cb ca) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4044 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4045
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4046 (defsubst org-cmp-time (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4047 "Compare the time-of-day values of strings a and b."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4048 (let* ((def (if org-sort-agenda-notime-is-late 2401 -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4049 (ta (or (get-text-property 1 'time-of-day a) def))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4050 (tb (or (get-text-property 1 'time-of-day b) def)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4051 (cond ((< ta tb) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4052 ((< tb ta) +1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4053 (t nil))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4054
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4055 (defun org-entries-lessp (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4056 "Predicate for sorting agenda entries."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4057 (let* ((time-up (org-cmp-time a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 (time-down (if time-up (- time-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4059 (priority-up (org-cmp-priority a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4060 (priority-down (if priority-up (- priority-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4061 (category-up (org-cmp-category a b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062 (category-down (if category-up (- category-up) nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4063 (category-keep (if category-up +1 nil))) ; FIXME +1 or -1?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 (cdr (assoc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4065 (eval (cons 'or org-agenda-sorting-strategy))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 '((-1 . t) (1 . nil) (nil . nil))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4067
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4068 (defun org-agenda-show-priority ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4069 "Show the priority of the current item.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4070 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
4071 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
4072 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4073 (let* ((pri (get-text-property (point-at-bol) 'priority)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4074 (message "Priority is %d" (if pri pri -1000))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4075
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4076 (defun org-agenda-goto ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 "Go to the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4080 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4083 (switch-to-buffer-other-window buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4085 (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
4086 (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
4087 (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
4088 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4089 (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
4090 (org-flag-heading nil)))))) ; show the next heading
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4091
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 (defun org-agenda-switch-to ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4093 "Go to the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4094 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4095 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4096 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4097 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4098 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4099 (switch-to-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4100 (delete-other-windows)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102 (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
4103 (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
4104 (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
4105 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4106 (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
4107 (org-flag-heading nil)))))) ; show the next heading
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109 (defun org-agenda-goto-mouse (ev)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4110 "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
4111 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4112 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4113 (org-agenda-goto))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4114
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4115 (defun org-agenda-show ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4116 "Display the Org-mode file which contains the item at point."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4117 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4118 (let ((win (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4119 (org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4120 (select-window win)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4121
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4122 (defun org-agenda-recenter (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4123 "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
4124 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4125 (let ((win (selected-window)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4126 (org-agenda-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4127 (recenter arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4128 (select-window win)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4129
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4130 (defun org-agenda-show-mouse (ev)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4131 "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
4132 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4133 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4134 (org-agenda-show))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4135
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4136 (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
4137 "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
4138 (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
4139 (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
4140
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4141 (defun org-agenda-error ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4142 (error "Command not allowed in this line."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4143
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4144 (defvar org-last-heading-marker (make-marker)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4145 "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
4146 by a remote command from the agenda.")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4147
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4148 (defun org-agenda-todo ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4149 "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
4150 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
4151 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
4152 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4153 (org-agenda-check-no-diary)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4154 (let* ((col (current-column))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4155 (marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4156 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4157 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4158 (pos (marker-position marker))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4159 (hdmarker (get-text-property (point) 'org-hd-marker))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4160 (buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4161 newhead)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4162 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4163 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4164 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4165 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4166 (org-show-hidden-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4167 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4168 (and (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4169 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4170 (org-todo)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4171 (forward-char 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4172 (setq newhead (org-get-heading))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4173 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4174 (org-back-to-heading)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4175 (move-marker org-last-heading-marker (point))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4176 (beginning-of-line 1)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4177 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4178 (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
4179 (move-to-column col)))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4180
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4181 (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
4182 "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
4183 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
4184 `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
4185 (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
4186 (save-excursion
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4187 (goto-char (point-max))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4188 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4189 (while (not (bobp))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4190 (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
4191 (equal m hdmarker))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4192 (setq props (text-properties-at (point))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4193 pl (get-text-property (point) 'prefix-length)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4194 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
4195 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
4196 (move-to-column pl)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4197 (if (looking-at ".*")
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4198 (progn
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4199 (replace-match newhead t t)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4200 (beginning-of-line 1)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4201 (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
4202 (if fixface
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4203 (add-text-properties
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4204 (point-at-bol) (point-at-eol)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4205 (list 'face
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4206 (if org-last-todo-state-is-todo
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4207 undone-face done-face))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4208 (beginning-of-line 1))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4209 (error "Line update did not work")))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4210 (beginning-of-line 0)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 (defun org-agenda-priority-up ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4213 "Increase the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (org-agenda-priority 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4217 (defun org-agenda-priority-down ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4218 "Decrease the priority of line at point, also in Org-mode file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4219 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4220 (org-agenda-priority 'down))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4221
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4222 (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
4223 "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
4224 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
4225 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
4226 (interactive)
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4227 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4228 (let* ((props (text-properties-at (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4229 (col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4230 (marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4231 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4232 (pl (get-text-property (point-at-bol) 'prefix-length))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4233 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4234 (pos (marker-position marker))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4235 (hdmarker (get-text-property (point) 'org-hd-marker))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4236 (buffer-read-only nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4237 newhead)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4238 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4239 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4240 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4241 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4242 (org-show-hidden-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4243 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4244 (and (outline-next-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4245 (org-flag-heading nil))) ; show the next heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4246 (funcall 'org-priority force-direction)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4247 (setq newhead (org-get-heading)))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4248 (org-agenda-change-all-lines newhead hdmarker)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4249 (beginning-of-line 1)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4250
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4251 (defun org-agenda-date-later (arg &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4252 "Change the date of this item to one day later."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4253 (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
4254 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4255 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4256 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4257 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4258 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4259 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4260 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4261 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4262 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4263 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4264 (error "Cannot find time stamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4265 (org-timestamp-change arg (or what 'day))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4266 (message "Time stamp changed to %s" org-last-changed-timestamp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4267
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268 (defun org-agenda-date-earlier (arg &optional what)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4269 "Change the date of this item to one day earlier."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4270 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4271 (org-agenda-date-later (- arg) what))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4272
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4273 (defun org-agenda-date-prompt (arg)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4274 "Change the date of this item. Date is prompted for, with default today."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4275 (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
4276 (org-agenda-check-no-diary)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4277 (let* ((marker (or (get-text-property (point) 'org-marker)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4278 (org-agenda-error)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4279 (buffer (marker-buffer marker))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4280 (pos (marker-position marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4281 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4282 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4283 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4284 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4285 (if (not (org-at-timestamp-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4286 (error "Cannot find time stamp"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4287 (org-time-stamp nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4288 (message "Time stamp changed to %s" org-last-changed-timestamp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4289
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4290 (defun org-get-heading ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4291 "Return the heading of the current entry, without the stars."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4292 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4293 (if (and (re-search-backward "[\r\n]\\*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4294 (looking-at "[\r\n]\\*+[ \t]+\\(.*\\)"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4295 (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4296 "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4297
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4298 (defun org-agenda-diary-entry (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4299 "Make a diary entry, like the `i' command from the calendar.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4300 All the standard commands work: block, weekly etc"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4301 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4302 (require 'diary-lib)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4303 (let* ((char (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4304 (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
4305 (read-char-exclusive)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4306 (cmd (cdr (assoc char
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4307 '((?d . insert-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4308 (?w . insert-weekly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4309 (?m . insert-monthly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4310 (?y . insert-yearly-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4311 (?a . insert-anniversary-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4312 (?b . insert-block-diary-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4313 (?c . insert-cyclic-diary-entry)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4314 (oldf (symbol-function 'calendar-cursor-to-date))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4315 (point (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4316 (mark (or (mark t) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4317 (unless cmd
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4318 (error "No command associated with <%c>" char))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4319 (unless (and (get-text-property point 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4320 (or (not (equal ?b char))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4321 (get-text-property mark 'day)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4322 (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
4323 ;; We implement this by hacking the `calendar-cursor-to-date' function
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4324 ;; and the `calendar-mark-ring' variable. Saves a lot of code.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4325 (let ((calendar-mark-ring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4326 (list (calendar-gregorian-from-absolute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4327 (or (get-text-property mark 'day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4328 (get-text-property point 'day))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4329 (unwind-protect
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4330 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4331 (fset 'calendar-cursor-to-date
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4332 (lambda (&optional error)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4333 (calendar-gregorian-from-absolute
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4334 (get-text-property point 'day))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4335 (call-interactively cmd))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4336 (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
4337
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4338
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4339 (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
4340 "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
4341 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
4342 (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
4343 (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
4344 (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
4345 (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
4346 (point (point))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4347 (mark (or (mark t) (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4348 (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
4349 (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
4350 (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
4351 (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
4352 (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
4353 (unwind-protect
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4354 (progn
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4355 (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
4356 (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
4357 (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
4358 (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
4359 (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
4360 (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
4361
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4362 (defun org-agenda-phases-of-moon ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4363 "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
4364 (interactive)
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-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
4366
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4367 (defun org-agenda-holidays ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4368 "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
4369 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4370 (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
4371
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4372 (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
4373 "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
4374 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
4375 `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
4376 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
4377 (interactive "P")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4378 (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
4379 (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
4380 (calendar-location-name
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4381 (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
4382 (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
4383
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4384 (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
4385 "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
4386 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4387 (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
4388 (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
4389 (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
4390 (calendar)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4391 (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
4392
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4393 (defun org-calendar-goto-agenda ()
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4394 "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
4395 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
4396 (interactive)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4397 (org-agenda nil (calendar-absolute-from-gregorian
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4398 (calendar-cursor-to-date))))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4399
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4400 (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
4401 (interactive)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4402 (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
4403 date s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4404 (unless day
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4405 (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
4406 (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
4407 (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
4408 "Gregorian: " (calendar-date-string date) "\n"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4409 "ISO: " (calendar-iso-date-string date) "\n"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4410 "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
4411 "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
4412 "Astronomic: " (calendar-astro-date-string date)
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4413 " (Julian date number at noon UTC)\n"
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
4414 "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
4415 "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
4416 "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
4417 "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
4418 "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
4419 "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
4420 "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
4421 "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
4422 (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
4423 (princ s))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
4424 (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
4425
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4426 ;;; Link Stuff
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4427
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4428 (defun org-find-file-at-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4429 "Open file link or URL at mouse."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4430 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4431 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4432 (org-open-at-point 'in-emacs))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4433
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4434 (defun org-open-at-mouse (ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4435 "Open file link or URL at mouse."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4436 (interactive "e")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4437 (mouse-set-point ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4438 (org-open-at-point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4439
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4440 (defun org-open-at-point (&optional in-emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4441 "Open link at or after point.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4442 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
4443 the end of the current subtree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4444 Normally, files will be opened by an appropriate application. If the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4445 optional argument IN-EMACS is non-nil, Emacs will visit the file."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4446 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4447 (if (org-at-timestamp-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4448 (org-agenda nil (time-to-days (org-time-string-to-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4449 (substring (match-string 1) 0 10)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4450 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4451 (let (type path line (pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4452 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4453 (skip-chars-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4454 (if org-allow-space-in-links "^\t\n\r" "^ \t\n\r"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4455 (if (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4456 org-link-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4457 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4458 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4459 (progn (outline-end-of-subtree) (max pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4460 (error (end-of-line 1) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4461 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4462 (setq type (match-string 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4463 path (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4464 (unless path
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4465 (error "No link found."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4466 ;; Remove any trailing spaces in path
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4467 (if (string-match " +\\'" path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4468 (setq path (replace-match "" t t path)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4469
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4470 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4471
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4472 ((string= type "file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4473 (if (string-match ":\\([0-9]+\\)\\'" path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4474 (setq line (string-to-number (match-string 1 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4475 path (substring path 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4476 (org-open-file path in-emacs line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4477
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4478 ((string= type "news")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4479 (org-follow-gnus-link path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4480
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4481 ((string= type "bbdb")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4482 (org-follow-bbdb-link path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4483
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4484 ((string= type "gnus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4485 (let (group article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4486 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4487 (error "Error in Gnus link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4488 (setq group (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4489 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4490 (org-follow-gnus-link group article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4491
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4492 ((string= type "vm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4493 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4494 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4495 (error "Error in VM link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4496 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4497 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4498 ;; in-emacs is the prefix arg, will be interpreted as read-only
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4499 (org-follow-vm-link folder article in-emacs)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4500
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4501 ((string= type "wl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4502 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4503 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4504 (error "Error in Wanderlust link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4505 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4506 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4507 (org-follow-wl-link folder article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4508
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4509 ((string= type "rmail")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4510 (let (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4511 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4512 (error "Error in RMAIL link"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4513 (setq folder (match-string 1 path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4514 article (match-string 3 path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4515 (org-follow-rmail-link folder article)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4516
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4517 ((string= type "shell")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4518 (let ((cmd path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4519 (if (or (not org-confirm-shell-links)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4520 (yes-or-no-p (format "Execute \"%s\" in the shell? " cmd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4521 (shell-command cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4522 (error "Abort"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4523
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4524 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4525 (browse-url-at-point)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4526
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4527 (defun org-follow-bbdb-link (name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4528 "Follow a BBDB link to NAME."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4529 (require 'bbdb)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4530 ;; First try an exact match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4531 (bbdb-name (concat "\\`" name "\\'") nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4532 (if (= 0 (buffer-size (get-buffer "*BBDB*")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4533 ;; No exact match - try partial match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4534 (bbdb-name name nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4535
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4536 (defun org-follow-gnus-link (&optional group article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4537 "Follow a Gnus link to GROUP and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4538 (require 'gnus)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4539 (funcall (cdr (assq 'gnus org-link-frame-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4540 (if group (gnus-fetch-group group))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4541 (if article
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4542 (or (gnus-summary-goto-article article nil 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4543 (if (fboundp 'gnus-summary-insert-cached-articles)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4544 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4545 (gnus-summary-insert-cached-articles)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4546 (gnus-summary-goto-article article nil 'force))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4547 (message "Message could not be found.")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4548 ;; (if article (gnus-summary-goto-article article nil 'force)))
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-follow-vm-link (&optional folder article readonly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4551 "Follow a VM link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4552 (require 'vm)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4553 (if (string-match "^//\\([a-zA-Z]+@\\)?\\([^:]+\\):\\(.*\\)" folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4554 ;; ange-ftp or efs or tramp access
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4555 (let ((user (or (match-string 1 folder) (user-login-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4556 (host (match-string 2 folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4557 (file (match-string 3 folder)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4558 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4559 ((featurep 'tramp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4560 ;; use tramp to access the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4561 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4562 (setq folder (format "[%s@%s]%s" user host file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4563 (setq folder (format "/%s@%s:%s" user host file))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4564 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4565 ;; use ange-ftp or efs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4566 (require (if org-xemacs-p 'efs 'ange-ftp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4567 (setq folder (format "/%s@%s:%s" user host file))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4568 (when folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4569 (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4570 (sit-for 0.1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4571 (when article
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4572 (vm-select-folder-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4573 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4574 (let ((case-fold-search t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4575 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4576 (if (not (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4577 (concat "^" "message-id: *" (regexp-quote article))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4578 (error "Could not find the specified message in this folder"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4579 (vm-isearch-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4580 (vm-isearch-narrow)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4581 (vm-beginning-of-message)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4582 (vm-summarize)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4583
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4584 (defun org-follow-wl-link (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4585 "Follow a Wanderlust link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4586 (wl-summary-goto-folder-subr folder 'no-sync t nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4587 (if article (wl-summary-jump-to-msg-by-message-id article))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4588 (wl-summary-redisplay))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4589
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4590 (defun org-follow-rmail-link (folder article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4591 "Follow an RMAIL link to FOLDER and ARTICLE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4592 (let (message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4593 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4594 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4595 (rmail (if (string= folder "RMAIL") rmail-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4596 (setq message-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4597 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4598 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4599 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4600 (if (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4601 (concat "^Message-ID:\\s-+" (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4602 (or article "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4603 nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4604 (rmail-what-message))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4605 (if message-number
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4606 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4607 (rmail (if (string= folder "RMAIL") rmail-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4608 (rmail-show-message message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4609 message-number)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4610 (error "Message not found"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4611
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4612 (defun org-open-file (path &optional in-emacs line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4613 "Open the file at PATH.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4614 First, this expands any special file name abbreviations. Then the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4615 configuration variable `org-file-apps' is checked if it contains an
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4616 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
4617 If no application is found, Emacs simply visits the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4618 With optional argument IN-EMACS, Emacs will visit the file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4619 If the file does not exist, an error is thrown."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4620 (let* ((file (convert-standard-filename (org-expand-file-name path)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4621 (dfile (downcase file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4622 ext cmd apps)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4623 (if (and (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4624 (not org-open-non-existing-files))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4625 (error "No such file: %s" file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4626 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\.gz\\)$" dfile)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4627 (setq ext (match-string 1 dfile))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4628 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4629 (setq ext (match-string 1 dfile))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4630 (setq apps (append org-file-apps (org-default-apps)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4631 (if in-emacs
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4632 (setq cmd 'emacs)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4633 (setq cmd (or (cdr (assoc ext apps))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4634 (cdr (assoc t apps)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4635 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4636 ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4637 (setq cmd (format cmd file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4638 (save-window-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4639 (shell-command (concat cmd " & &"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4640 ((or (stringp cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4641 (eq cmd 'emacs))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4642 (funcall (cdr (assq 'file org-link-frame-setup)) file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4643 (if line (goto-line line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4644 ((consp cmd)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4645 (eval cmd))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4646 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4647
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4648 (defun org-default-apps ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4649 "Return the default applications for this operating system."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4650 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4651 ((eq system-type 'darwin)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4652 org-file-apps-defaults-macosx)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4653 ((eq system-type 'windows-nt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4654 org-file-apps-defaults-windowsnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4655 ((eq system-type 'linux)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4656 org-file-apps-defaults-linux)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4657 (t org-file-apps-defaults-linux)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4658
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4659 (defun org-expand-file-name (path)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4660 "Replace special path abbreviations and expand the file name."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4661 (expand-file-name path))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4662
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4663
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4664 (defvar org-insert-link-history nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4665 "Minibuffer history for links inserted with `org-insert-link'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4666
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4667 (defvar org-stored-links nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4668 "Contains the links stored with `org-store-link'.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4669
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4670 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4671 (defun org-store-link (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4672 "\\<org-mode-map>Store an org-link to the current location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4673 This link can later be inserted into an org-buffer with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4674 \\[org-insert-link].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4675 For some link types, a prefix arg is interpreted:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4676 For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4677 For file links, arg negates `org-line-numbers-in-file-links'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4678 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4679 (let (link cpltxt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4680 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4681
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4682 ((eq major-mode 'bbdb-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4683 (setq link (concat "bbdb:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4684 (bbdb-record-name (bbdb-current-record)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4685
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4686 ((eq major-mode 'calendar-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4687 (let ((cd (calendar-cursor-to-date)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4688 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4689 (format-time-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4690 (car org-time-stamp-formats)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4691 (apply 'encode-time
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4692 (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
4693 nil nil nil))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4694
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4695 ((or (eq major-mode 'vm-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4696 (eq major-mode 'vm-presentation-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4697 (and (eq major-mode 'vm-presentation-mode) (vm-summarize))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4698 (vm-follow-summary-cursor)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4699 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4700 (vm-select-folder-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4701 (let* ((message (car vm-message-pointer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4702 (folder (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4703 (subject (vm-su-subject message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4704 (author (vm-su-full-name message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4705 (address (vm-su-from message))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4706 (message-id (vm-su-message-id message)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4707 (setq folder (abbreviate-file-name folder))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4708 (if (string-match (concat "^" (regexp-quote vm-folder-directory))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4709 folder)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4710 (setq folder (replace-match "" t t folder)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4711 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4712 (setq link (concat cpltxt "\n " "vm:" folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4713 "#" message-id)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4714
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4715 ((eq major-mode 'wl-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4716 (let* ((msgnum (wl-summary-message-number))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4717 (message-id (elmo-message-field wl-summary-buffer-elmo-folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4718 msgnum 'message-id))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4719 (wl-message-entity (elmo-msgdb-overview-get-entity
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4720 msgnum (wl-summary-buffer-msgdb)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4721 (author (wl-summary-line-from)) ; FIXME: how to get author name?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4722 (subject "???")) ; FIXME: How to get subject of email?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4723 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4724 (setq link (concat cpltxt "\n " "wl:" wl-summary-buffer-folder-name
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4725 "#" message-id))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4726
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4727 ((eq major-mode 'rmail-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4728 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4729 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4730 (rmail-narrow-to-non-pruned-header)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4731 (let ((folder (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4732 (message-id (mail-fetch-field "message-id"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4733 (author (mail-fetch-field "from"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4734 (subject (mail-fetch-field "subject")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4735 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4736 (setq link (concat cpltxt "\n " "rmail:" folder
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4737 "#" message-id))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4738
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4739 ((eq major-mode 'gnus-group-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4740 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4741 (gnus-group-group-name)) ; version
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4742 ((fboundp 'gnus-group-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4743 (gnus-group-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4744 (t "???"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4745 (if (org-xor arg org-usenet-links-prefer-google)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4746 (setq link (format "http://groups.google.com/groups?group=%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4747 group))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4748 (setq link (concat "gnus:" group)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4749
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4750 ((or (eq major-mode 'gnus-summary-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4751 (eq major-mode 'gnus-article-mode))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4752 (gnus-article-show-summary)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4753 (gnus-summary-beginning-of-article)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4754 (let* ((group (car gnus-article-current))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4755 (article (cdr gnus-article-current))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4756 (header (gnus-summary-article-header article))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4757 (author (mail-header-from header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4758 (message-id (mail-header-id header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4759 (date (mail-header-date header))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4760 (subject (gnus-summary-subject-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4761 (setq cpltxt (concat author " on: " subject))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4762 (if (org-xor arg org-usenet-links-prefer-google)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4763 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4764 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4765 cpltxt "\n "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4766 (format "http://groups.google.com/groups?as_umsgid=%s"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4767 (org-fixup-message-id-for-http message-id))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4768 (setq link (concat cpltxt "\n" "gnus:" group
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4769 "#" (number-to-string article))))))
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 ((eq major-mode 'w3-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4772 (setq link (url-view-url t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4773 ((eq major-mode 'w3m-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4774 (setq link w3m-current-url))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4775
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4776 ((buffer-file-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4777 ;; Just link to this file here.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4778 (setq link (concat "file:"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4779 (abbreviate-file-name (buffer-file-name))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4780 ;; Add the line number?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4781 (if (org-xor org-line-numbers-in-file-links arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4782 (setq link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4783 (concat link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4784 ":" (int-to-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4785 (+ (if (bolp) 1 0) (count-lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4786 (point-min) (point))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4787 ((interactive-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4788 (error "Cannot link to a buffer which is not visiting a file"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4789 (t (setq link nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4790
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4791 (if (and (interactive-p) link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4792 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4793 (setq org-stored-links
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4794 (cons (cons (or cpltxt link) link) org-stored-links))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4795 (message "Stored: %s" (or cpltxt link)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4796 link)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4797
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4798 (defun org-xor (a b)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4799 "Exclusive or."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4800 (or (and a (not b))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4801 (and b (not a))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4802
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4803 (defun org-get-header (header)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4804 "Find a header field in the current buffer."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4805 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4806 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4807 (let ((case-fold-search t) s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4808 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4809 ((eq header 'from)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4810 (if (re-search-forward "^From:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4811 (setq s (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4812 (while (string-match "\"" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4813 (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4814 (if (string-match "[<(].*" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4815 (setq s (replace-match "" t t s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4816 ((eq header 'message-id)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4817 (if (re-search-forward "^message-id:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4818 (setq s (match-string 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4819 ((eq header 'subject)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4820 (if (re-search-forward "^subject:\\s-+\\(.*\\)" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4821 (setq s (match-string 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4822 (if (string-match "\\`[ \t\]+" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4823 (if (string-match "[ \t\]+\\'" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4824 s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4825
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4826
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4827 (defun org-fixup-message-id-for-http (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4828 "Replace special characters in a message id, so that it can be used
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4829 in an http query."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4830 (while (string-match "<" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4831 (setq s (replace-match "%3C" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4832 (while (string-match ">" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4833 (setq s (replace-match "%3E" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4834 (while (string-match "@" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4835 (setq s (replace-match "%40" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4836 s)
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 (defun org-insert-link (&optional complete-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4839 "Insert a link. At the prompt, enter the link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4840
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4841 Completion can be used to select a link previously stored with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4842 `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
4843 press RET at the prompt), the link defaults to the most recently
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4844 stored link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4845
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4846 With a C-u prefix, prompts for a file to link to. The file name can be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4847 selected using completion. The path to the file will be relative to
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4848 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
4849 subdirectory. Otherwise, the link will be the absolute path as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4850 completed in the minibuffer (i.e. normally ~/path/to/file).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4851
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4852 With two C-u prefixes, enforce an absolute path even if the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4853 is in the current directory or below."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4854 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4855 (let ((link (if complete-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4856 (read-file-name "File: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4857 (completing-read
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4858 "Link: " org-stored-links nil nil nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4859 org-insert-link-history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4860 (or (car (car org-stored-links))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4861 linktxt matched)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4862 (if (or (not link) (equal link ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4863 (error "No links available"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4864 (if complete-file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4865 (let ((pwd (file-name-as-directory (expand-file-name "."))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4866 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4867 ((equal complete-file '(16))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4868 (insert "file:" (abbreviate-file-name (expand-file-name link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4869 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4870 (expand-file-name link))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4871 (insert "file:" (match-string 1 (expand-file-name link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4872 (t (insert "file:" link))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4873 (setq linktxt (cdr (assoc link org-stored-links)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4874 (if (not org-keep-stored-link-after-insertion)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4875 (setq org-stored-links (delq (assoc link org-stored-links)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4876 org-stored-links)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4877 (let ((lines (org-split-string (or linktxt link) "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4878 (insert (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4879 (setq matched (string-match org-link-regexp (car lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4880 (setq lines (cdr lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4881 (while lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4882 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4883 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4884 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4885 (looking-at "[ \t]+\\S-"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4886 (indent-relative))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4887 (setq matched (or matched
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4888 (string-match org-link-regexp (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4889 (insert (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4890 (setq lines (cdr lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4891 (unless matched
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4892 (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
4893
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4894 ;;; Hooks for remember.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4895 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 (defun org-remember-annotation ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4897 "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
4898 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
4899 remember.el, then the annotations should include a link compatible with the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4900 conventions in Org-mode. This function returns such a link."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4901 (org-store-link nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4902
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4903 (defconst org-remember-help
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4904 "Select a destination location for the note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4905 UP/DOWN=headline TAB=cycle visibility [Q]uit RET/<left>/<right>=Store
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4906 RET at beg-of-buf -> Append to file as level 2 headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4907 RET on headline -> Store as sublevel entry to current headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4908 <left>/<right> -> before/after current headline, same headings level")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4909
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4910 ;;;###autoload
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4911 (defun org-remember-handler ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4912 "Store stuff from remember.el into an org file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4913 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
4914 of `org-default-notes-file' is used.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4915 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
4916 file the text at a specific location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 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
4918 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
4919 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
4920
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4921 Key Cursor position Note gets inserted
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4922 -----------------------------------------------------------------------------
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4923 RET buffer-start as level 2 heading at end of file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924 RET on headline as sublevel of the heading at cursor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4925 RET no heading at cursor position, level taken from context.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4926 Or use prefix arg to specify level manually.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4927 <left> on headline as same level, before current heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4928 <right> on headline as same level, after current heading
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4929
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4930 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
4931 the default file. This way your current train of thought is not
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4932 interrupted, in accordance with the principles of remember.el. But with
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4933 little extra effort, you can push it directly to the correct location.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4934
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4935 Before being stored away, the function ensures that the text has a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936 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
4937 is constructed from the current date and some additional data.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4938
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4939 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
4940 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
4941 \(i.e. after the stars).
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4942
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4943 See also the variable `org-reverse-note-order'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4944 (catch 'quit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4945 (let* ((txt (buffer-substring (point-min) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4946 (fastp current-prefix-arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4947 (file (if fastp org-default-notes-file (org-get-org-file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4948 (visiting (find-buffer-visiting file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4949 (org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4950 (org-startup-folded nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4951 spos level indent reversed)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4952 ;; 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
4953 ;; into an org tree.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4954 (let* ((lines (split-string txt "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4955 (first (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4956 (lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4957 (if (string-match "^\\*+" first)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4958 ;; Is already a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4959 (setq indent (make-string (- (match-end 0) (match-beginning 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4960 -1) ?\ ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4961 ;; We need to add a headline: Use time and first buffer line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4962 (setq lines (cons first lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4963 first (concat "* " (current-time-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4964 " (" (remember-buffer-desc) ")")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4965 indent " "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4966 (if org-adapt-indentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4967 (setq lines (mapcar (lambda (x) (concat indent x)) lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4968 (setq txt (concat first "\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4969 (mapconcat 'identity lines "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4970 ;; Find the file
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4971 (if (not visiting)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4972 (find-file-noselect file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4973 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4974 (set-buffer (get-file-buffer file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4975 (setq reversed (org-notes-order-reversed-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4976 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4977 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4978 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4979 ;; Ask the User for a location
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4980 (setq spos (if fastp 1 (org-get-location
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4981 (current-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4982 org-remember-help)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4983 (if (not spos) (throw 'quit nil)) ; return nil to show we did
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4984 ; not handle this note
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985 (goto-char spos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4986 (cond ((bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4987 ;; Put it at the start or end, as level 2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4988 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4989 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4990 (goto-char (if reversed (point-min) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4991 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4992 (org-paste-subtree (or current-prefix-arg 2) txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4993 ((and (org-on-heading-p nil) (not current-prefix-arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4994 ;; Put it below this entry, at the beg/end of the subtree
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4995 (org-back-to-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4996 (setq level (outline-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4997 (if reversed
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4998 (outline-end-of-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4999 (outline-end-of-subtree))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5000 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5001 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5002 (org-paste-subtree (1+ level) txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5003 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5004 ;; Put it right there, with automatic level determined by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5005 ;; org-paste-subtree or from prefix arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5006 (org-paste-subtree current-prefix-arg txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5007 (when remember-save-after-remembering
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5008 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5009 (if (not visiting) (kill-buffer (current-buffer)))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5010 t) ;; return t to indicate that we took care of this note.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5011
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5012 (defun org-get-org-file ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5013 "Read a filename, with default directory `org-directory'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5014 (let ((default (or org-default-notes-file remember-data-file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5015 (read-file-name (format "File name [%s]: " default)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5016 (file-name-as-directory org-directory)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5017 default)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5018
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5019 (defun org-notes-order-reversed-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5020 "Check if the current file should receive notes in reversed order."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5021 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5022 ((not org-reverse-note-order) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023 ((eq t org-reverse-note-order) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024 ((not (listp org-reverse-note-order)) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5025 (t (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5026 (let ((all org-reverse-note-order)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5027 entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028 (while (setq entry (pop all))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029 (if (string-match (car entry) (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5030 (throw 'exit (cdr entry))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5031 nil)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5032
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5033 ;;; Tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5034
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5035 ;; Watch out: Here we are talking about two different kind of tables.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5036 ;; 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
5037 ;; Sometimes, we talk about tables created and edited with the table.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5038 ;; Emacs package. We call the former org-type tables, and the latter
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5039 ;; table.el-type tables.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5040
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5041 ;; We use a before-change function to check if a table might need
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5042 ;; an update.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5043 (defvar org-table-may-need-update t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5044 "Indicates of a table might need an update.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5045 This variable is set by `org-before-change-function'. `org-table-align'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5046 sets it back to nil.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5047
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5048 (defun org-before-change-function (beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5049 "Every change indicates that a table might need an update."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5050 (setq org-table-may-need-update t))
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 (defconst org-table-line-regexp "^[ \t]*|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5053 "Detects an org-type table line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5054 (defconst org-table-dataline-regexp "^[ \t]*|[^-]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5055 "Detects an org-type table line.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5056 (defconst org-table-hline-regexp "^[ \t]*|-"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5057 "Detects an org-type table hline.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5058 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5059 "Detects a table-type table hline.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5060 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5061 "Detects an org-type or table-type table")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5062 (defconst org-table-border-regexp "^[ \t]*[^| \t]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5063 "Searching from within a table (any type) this finds the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5064 outside the table.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5065 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5066 "Searching from within a table (any type) this finds the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5067 outside the table.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5068
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5069 (defun org-table-create-with-table.el ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5070 "Use the table.el package to insert a new table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5071 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
5072 and table.el tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5073 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5074 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5075 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5076 ((org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5077 (if (y-or-n-p "Convert table to Org-mode table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5078 (org-table-convert)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5079 ((org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5080 (if (y-or-n-p "Convert table to table.el table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5081 (org-table-convert)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5082 (t (call-interactively 'table-insert))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5083
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5084 (defun org-table-create (&optional size)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5085 "Query for a size and insert a table skeleton.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5086 SIZE is a string Columns x Rows like for example \"3x2\"."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5087 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5088 (unless size
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5089 (setq size (read-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5090 (concat "Table size Columns x Rows [e.g. "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5091 org-table-default-size "]: ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5092 "" nil org-table-default-size)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5093
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5094 (let* ((pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5095 (indent (make-string (current-column) ?\ ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5096 (split (org-split-string size " *x *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5097 (rows (string-to-number (nth 1 split)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5098 (columns (string-to-number (car split)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5099 (line (concat (apply 'concat indent "|" (make-list columns " |"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5100 "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5101 (if (string-match "^[ \t]*$" (buffer-substring-no-properties
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5102 (point-at-bol) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5103 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5104 (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5105 (mapcar (lambda (x) (insert line)) (make-list rows t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5106 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5107 (if (> rows 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5108 ;; Insert a hline after the first row.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5109 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5110 (end-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5111 (insert "\n|-")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5112 (goto-char pos)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5113 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5114
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5115 (defun org-table-convert-region (beg0 end0 nspace)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5116 "Convert region to a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5117 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
5118 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
5119 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
5120 separate columns (default: just one space)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5121 (let* ((beg (min beg0 end0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5122 (end (max beg0 end0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5123 (tabsep t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5124 re)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5125 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5126 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5127 (setq beg (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5128 (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5129 (if (bolp) (backward-char 1) (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5130 (setq end (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5131 ;; Lets see if this is tab-separated material. If every nonempty line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5132 ;; contains a tab, we will assume that it is tab-separated material
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5133 (if nspace
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5134 (setq tabsep nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5135 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5136 (and (re-search-forward "^[^\n\t]+$" end t) (setq tabsep nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5137 (if nspace (setq tabsep nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5138 (if tabsep
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5139 (setq re "^\\|\t")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5140 (setq re (format "^ *\\| *\t *\\| \\{%d,\\}"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5141 (max 1 (prefix-numeric-value nspace)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5142 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5143 (while (re-search-forward re end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5144 (replace-match "|" t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5145 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5146 (insert " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5147 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5148
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5149 (defun org-table-import (file arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5150 "Import FILE as a table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5151 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
5152 spreadsheet and database applications. If no tabs (at least one per line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5153 are found, lines will be split on whitespace into fields."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5154 (interactive "f\nP")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5155 (or (bolp) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5156 (let ((beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5157 (pm (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5158 (insert-file-contents file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5159 (org-table-convert-region beg (+ (point) (- (point-max) pm)) arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5160
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5161 (defun org-table-export ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5162 "Export table as a tab-separated file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5163 Such a file can be imported into a spreadsheet program like Excel."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5164 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5165 (let* ((beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5166 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5167 (table (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5168 (file (read-file-name "Export table to: "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5169 buf)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5170 (unless (or (not (file-exists-p file))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5171 (y-or-n-p (format "Overwrite file %s? " file)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5172 (error "Abort"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5173 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5174 (find-file file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5175 (setq buf (current-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5176 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5177 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5178 (insert table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5179 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5180 (while (re-search-forward "^[ \t]*|[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5181 (replace-match "" t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5182 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5183 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5184 (while (re-search-forward "[ \t]*|[ \t]*$" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5185 (replace-match "" t t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5186 (goto-char (min (1+ (point)) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5187 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5188 (while (re-search-forward "^-[-+]*$" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5189 (replace-match "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5190 (if (looking-at "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5191 (delete-char 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5192 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5193 (while (re-search-forward "[ \t]*|[ \t]*" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5194 (replace-match "\t" t t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5195 (save-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5196 (kill-buffer buf)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5197
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5198 (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
5199 "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
5200 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
5201 (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
5202 "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
5203 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
5204 (defvar org-table-last-alignment nil
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5205 "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
5206 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
5207 ;; 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
5208 (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
5209 "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
5210 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
5211
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5212
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5213 (defun org-table-align (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5214 "Align the table at point by aligning all vertical bars."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5215 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5216 (let* (
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5217 ;; Limits of table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5218 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5219 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5220 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5221 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5222 (colpos (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5223 (winstart (window-start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5224 text lines (new "") lengths l typenums ty fields maxfields i
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5225 column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5226 (indent "") cnt frac
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5227 rfmt hfmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5228 (spaces (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5229 org-table-spaces-around-invisible-separators
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5230 org-table-spaces-around-separators))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5231 (sp1 (car spaces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5232 (sp2 (cdr spaces))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5233 (rfmt1 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5234 (make-string sp2 ?\ ) "%%%s%ds" (make-string sp1 ?\ ) "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5235 (hfmt1 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5236 (make-string sp2 ?-) "%s" (make-string sp1 ?-) "+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5237 emptystrings)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5238 (untabify beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5239 ;; (message "Aligning table...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5240 ;; Get the rows
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5241 (setq lines (org-split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5242 (buffer-substring-no-properties beg end) "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5243 ;; Store the indentation of the first line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5244 (if (string-match "^ *" (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5245 (setq indent (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5246 ;; Mark the hlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5247 (setq lines (mapcar (lambda (l) (if (string-match "^ *|-" l) nil l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5248 lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5249 ;; Get the data fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5250 (setq fields (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5251 (lambda (l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5252 (org-split-string l " *| *"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5253 (delq nil (copy-sequence lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5254 ;; How many fields in the longest line?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5255 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5256 (setq maxfields (apply 'max (mapcar 'length fields)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5257 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5258 (kill-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5259 (org-table-create org-table-default-size)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5260 (error "Empty table - created default table")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5261 ;; A list of empty string to fill any short rows on output
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5262 (setq emptystrings (make-list maxfields ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5263 ;; Get the maximum length of a field and the most common datatype
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5264 ;; for each column
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5265 (setq i -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5266 (while (< (setq i (1+ i)) maxfields) ;; Loop over all columns
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5267 (setq column (mapcar (lambda (x) (or (nth i x) "")) fields))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5268 ;; maximum length
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5269 (push (apply 'max 1 (mapcar 'length column)) lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5270 ;; compute the fraction stepwise, ignoring empty fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5271 (setq cnt 0 frac 0.0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5272 (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5273 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5274 (if (equal x "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5275 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5276 (setq frac ( / (+ (* frac cnt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5277 (if (string-match org-table-number-regexp x) 1 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5278 (setq cnt (1+ cnt))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5279 column)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5280 (push (>= frac org-table-number-fraction) typenums))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5281 (setq lengths (nreverse lengths)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5282 typenums (nreverse typenums))
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5283 (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
5284 org-table-last-column-widths lengths)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5285 ;; Compute the formats needed for output of the table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5286 (setq rfmt (concat indent "|") hfmt (concat indent "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5287 (while (setq l (pop lengths))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5288 (setq ty (if (pop typenums) "" "-")) ; number types flushright
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5289 (setq rfmt (concat rfmt (format rfmt1 ty l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5290 hfmt (concat hfmt (format hfmt1 (make-string l ?-)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5291 (setq rfmt (concat rfmt "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5292 hfmt (concat (substring hfmt 0 -1) "|\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5293 ;; Produce the new table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5294 (while lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5295 (setq l (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5296 (if l
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5297 (setq new (concat new (apply 'format rfmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5298 (append (pop fields) emptystrings))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5299 (setq new (concat new hfmt))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5300 ;; Replace the old one
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5301 (delete-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5302 (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
5303 (move-marker org-table-aligned-begin-marker (point))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5304 (insert new)
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5305 (move-marker org-table-aligned-end-marker (point))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5306 ;; Try to move to the old location (approximately)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5307 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5308 (set-window-start (selected-window) winstart 'noforce)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5309 (org-table-goto-column colpos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5310 (setq org-table-may-need-update nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5311 (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5312 (org-table-add-invisible-to-vertical-lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5313 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5314
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5315 (defun org-table-begin (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5316 "Find the beginning of the table and return its position.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5317 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
5318 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5319 (if (not (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5320 (if table-type org-table-any-border-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5321 org-table-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5322 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5323 (error "Can't find beginning of table")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5324 (goto-char (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5325 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5326 (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5327
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5328 (defun org-table-end (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5329 "Find the end of the table and return its position.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5330 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
5331 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5332 (if (not (re-search-forward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5333 (if table-type org-table-any-border-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5334 org-table-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5335 nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5336 (goto-char (point-max))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5337 (goto-char (match-beginning 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5338 (point-marker)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5339
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5340 (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
5341 "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
5342 (cond
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5343 (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
5344 ((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
5345 ;; 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
5346 (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
5347 ((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
5348 (current-buffer)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5349 (< (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
5350 (>= (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
5351 ;; 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
5352 (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
5353 (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
5354 (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
5355 (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
5356 (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
5357 l f)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5358 (when (> col 0)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5359 (skip-chars-backward "^|\n")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5360 (if (looking-at " *\\([^|\n]*?\\) *|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5361 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5362 (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
5363 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
5364 (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
5365 (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
5366 (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
5367 (goto-char pos))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5368
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5369 (defun org-table-next-field (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5370 "Go to the next field in the current table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5371 Before doing so, re-align the table if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5372 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5373 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5374 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5375 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5376 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5377 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5378 (condition-case nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5379 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5380 (re-search-forward "|" (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5381 (if (looking-at "[ \t]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5382 (re-search-forward "|" (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5383 (if (looking-at "-")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5384 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5385 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5386 (org-table-insert-row 'below))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5387 (if (looking-at " ") (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5388 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5389 (org-table-insert-row 'below))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5390
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5391 (defun org-table-previous-field (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5392 "Go to the previous field in the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5393 Before doing so, re-align the table if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5394 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5395 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5396 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5397 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5398 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5399 (end-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5400 (re-search-backward "|" (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5401 (re-search-backward "|" (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5402 (while (looking-at "|\\(-\\|[ \t]*$\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403 (re-search-backward "|" (org-table-begin)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5404 (if (looking-at "| ?")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5405 (goto-char (match-end 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5406
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5407 (defun org-table-next-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 "Go to the next row (same column) in the current table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5409 Before doing so, re-align the table if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5410 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411 (if (or (looking-at "[ \t]*$")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5412 (save-excursion (skip-chars-backward " \t") (bolp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5413 (newline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5414 (if (and org-table-automatic-realign
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5415 org-table-may-need-update)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5416 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5417 (let ((col (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5418 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419 (if (or (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5420 (org-at-table-hline-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5421 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5422 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5423 (org-table-insert-row 'below)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5424 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (skip-chars-backward "^|\n\r")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5426 (if (looking-at " ") (forward-char 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5427
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5428 (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
5429 "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
5430 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
5431 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
5432 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
5433 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
5434 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
5435 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
5436 integer, it will be incremented while copying."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5437 (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
5438 (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
5439 (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
5440 (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
5441 (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
5442 txt)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5443 (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
5444 (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
5445 (if (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5446 (setq txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5447 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5448 (while (progn (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5449 (re-search-backward org-table-dataline-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5450 beg t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5451 (org-table-goto-column colpos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5452 (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
5453 "|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|")
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5454 (= (setq n (1- n)) 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5455 (throw 'exit (match-string 1)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5456 (progn
61134
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
5457 (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
5458 (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
5459 (setq txt (format "%d" (+ (string-to-int txt) 1))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5460 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5461 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5462 (error "No non-empty field found"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5463
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5464 (defun org-table-check-inside-data-field ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5465 "Is point inside a table data field?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5466 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
5467 (if (or (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5468 (= (org-table-current-column) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5469 (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5470 (looking-at "[ \t]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5471 (error "Not in table data field")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5472
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5473 (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
5474 "Blank the current table field or active region."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5475 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5476 (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
5477 (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
5478 (let (org-table-clip)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5479 (org-table-cut-region))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5480 (skip-chars-backward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5481 (backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5482 (if (looking-at "|[^|]+")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5483 (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
5484 (match (match-string 0))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5485 (len (length match)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5486 (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
5487 (goto-char (+ 2 pos))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5488 (substring match 1)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5490 (defun org-table-get-field (&optional n replace)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5491 "Return the value of the field in column N of current row.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5492 N defaults to current field.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5493 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
5494 is always the old value."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5495 (and n (org-table-goto-column n))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5496 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5497 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5498 (if (looking-at "|[^|\r\n]*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5499 (let* ((pos (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5500 (len (length (match-string 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5501 (val (buffer-substring (1+ pos) (match-end 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5502 (if replace
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5503 (replace-match (concat "|" replace)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5504 (goto-char (+ 2 pos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5505 val)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5506
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5507 (defun org-table-current-column ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5508 "Find out which column we are in.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5509 When called interactively, column is also displayed in echo area."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5510 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5511 (if (interactive-p) (org-table-check-inside-data-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5512 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5513 (let ((cnt 0) (pos (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5514 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5515 (while (search-forward "|" pos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5516 (setq cnt (1+ cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5517 (if (interactive-p) (message "This is table column %d" cnt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5518 cnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5519
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5520 (defun org-table-goto-column (n &optional on-delim force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5521 "Move the cursor to the Nth column in the current table line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5522 With optional argument ON-DELIM, stop with point before the left delimiter
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5523 of the field.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5524 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
5525 However, when FORCE is non-nil, create new columns if necessary."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5526 (let ((pos (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5527 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5528 (when (> n 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5529 (while (and (> (setq n (1- n)) -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5530 (or (search-forward "|" pos t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5531 (and force
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5532 (progn (end-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5533 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5534 (insert " |")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5535 (backward-char 2) t)))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5536 (when (and force (not (looking-at ".*|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5537 (save-excursion (end-of-line 1) (insert "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5538 (if on-delim
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5539 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5540 (if (looking-at " ") (forward-char 1))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5541
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5542 (defun org-at-table-p (&optional table-type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5543 "Return t if the cursor is inside an org-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5544 (if org-enable-table-editor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5545 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5546 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5547 (looking-at (if table-type org-table-any-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5548 org-table-line-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5549 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5550
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5551 (defun org-table-recognize-table.el ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5552 "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
5553 (if org-table-tab-recognizes-table.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5554 (if (org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5555 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5556 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5557 (if (looking-at org-table-dataline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5558 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5559 (if (looking-at org-table1-hline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5560 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5561 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5562 (if (looking-at org-table-any-border-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5563 (beginning-of-line -1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5564 (if (re-search-forward "|" (org-table-end t) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5565 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5566 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5567 (if (table--at-cell-p (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5568 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5569 (message "recognizing table.el table...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5570 (table-recognize-table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5571 (message "recognizing table.el table...done")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5572 (error "This should not happen..."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5573 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5574 nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5575 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5577 (defun org-at-table.el-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5578 "Return t if the cursor is inside a table.el-type table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5579 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5580 (if (org-at-table-p 'any)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5582 (goto-char (org-table-begin 'any))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5583 (looking-at org-table1-hline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5584 nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5585
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5586 (defun org-at-table-hline-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5587 "Return t if the cursor is inside a hline in a table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5588 (if org-enable-table-editor
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5589 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5590 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5591 (looking-at org-table-hline-regexp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5592 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5593
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5594 (defun org-table-insert-column (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5595 "Insert a new column into the table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5596 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5597 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5598 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5599 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5600 (let* ((col (max 1 (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5601 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5602 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5603 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5604 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5605 (colpos col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5606 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5607 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5608 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5609 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5610 (org-table-goto-column col t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5611 (insert "| "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5612 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5613 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5614 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5615 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5616 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5617
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5618 (defun org-table-find-dataline ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5619 "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
5620 (if (and (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5621 (not (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5622 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5623 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5624 (end (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5625 (move-to-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5626 (while (and (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5627 (or (not (= (current-column) col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5628 (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5629 (beginning-of-line 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5630 (move-to-column col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5631 (if (and (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5632 (not (org-at-table-hline-p)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5633 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5634 (error
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5635 "Please position cursor in a data line for column operations")))))
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-delete-column (&optional arg)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5638 "Delete a column into the table."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5639 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5640 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5641 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5642 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5643 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5644 (let* ((col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5645 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5646 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5647 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5648 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5649 (colpos col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5650 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5651 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5652 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5653 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5654 (org-table-goto-column col t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5655 (and (looking-at "|[^|\n]+|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5656 (replace-match "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5657 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5658 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5659 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5660 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5661 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5662
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5663 (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
5664 "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
5665 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5666 (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
5667 (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
5668 "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
5669 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5670 (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
5671
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5672 (defun org-table-move-column (&optional left)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5673 "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
5674 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5675 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5676 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5677 (org-table-find-dataline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5678 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5679 (let* ((col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5680 (col1 (if left (1- col) col))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5681 (beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5682 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5683 ;; Current cursor position
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5684 (linepos (+ (if (bolp) 1 0) (count-lines (point-min) (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5685 (colpos (if left (1- col) (1+ col))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5686 (if (and left (= col 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5687 (error "Cannot move column further left"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5688 (if (and (not left) (looking-at "[^|\n]*|[^|\n]*$"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5689 (error "Cannot move column further right"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5690 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5691 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5692 (if (org-at-table-hline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5693 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5694 (org-table-goto-column col1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5695 (and (looking-at "|\\([^|\n]+\\)|\\([^|\n]+\\)|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5696 (replace-match "|\\2|\\1|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5697 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5698 (move-marker end nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5699 (goto-line linepos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5700 (org-table-goto-column colpos))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5701 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5702
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5703 (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
5704 "Move table row down."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5705 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5706 (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
5707 (defun org-table-move-row-up ()
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5708 "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
5709 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
5710 (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
5711
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5712 (defun org-table-move-row (&optional up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5713 "Move the current table line down. With arg UP, move it up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5714 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5715 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5716 (pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5717 (tonew (if up 0 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5718 txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5719 (beginning-of-line tonew)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5720 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5721 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5722 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5723 (error "Cannot move row further.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5724 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5725 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5726 (setq pos (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5727 (setq txt (buffer-substring (point) (1+ (point-at-eol))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5728 (delete-region (point) (1+ (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5729 (beginning-of-line tonew)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5730 (insert txt)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5731 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5732 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5733
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5734 (defun org-table-insert-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5735 "Insert a new row above the current line into the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5736 With prefix ARG, insert below the current line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5737 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5738 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5739 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5740 (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5741 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5742 (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5743 (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5744 (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
5745 (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
5746 (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
5747 (insert-before-markers "\n"))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5748 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5749 (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
5750 (and org-table-may-need-update (org-table-align))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5751
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5752 (defun org-table-insert-hline (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5753 "Insert a horizontal-line below the current line into the table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5754 With prefix ARG, insert above the current line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5755 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5756 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5757 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5758 (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5759 (col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5760 start)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5761 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5762 (setq line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5763 (mapcar (lambda (x) (if (member x '(?| ?+))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5764 (prog1 (if start ?+ ?|) (setq start t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5765 (if start ?- ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5766 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5767 (setq line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5768 (mapcar (lambda (x) (if (equal x ?|)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5769 (prog1 (if start ?+ ?|) (setq start t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5770 (if start ?- ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5771 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5772 (beginning-of-line (if arg 1 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5773 (apply 'insert line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5774 (if (equal (char-before (point)) ?+)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5775 (progn (backward-delete-char 1) (insert "|")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5776 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5777 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5778 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5779
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5780 (defun org-table-kill-row (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5781 "Delete the current row or horizontal line from the table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5782 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5783 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5784 (error "Not at a table"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5785 (let ((col (current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5786 (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5787 (if (not (org-at-table-p)) (beginning-of-line 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5788 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5789
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5790
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5791 (defun org-table-cut-region (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5792 "Copy region in table to the clipboard and blank all relevant fields."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5793 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5794 (org-table-copy-region 'cut))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5795
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5796 (defvar org-table-clip nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5797 "Clipboard for table regions")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5798
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5799 (defun org-table-copy-region (&optional cut)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5800 "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
5801 A special clipboard is used which can only be accessed
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5802 with `org-table-paste-rectangle'"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5803 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5804 (unless (org-region-active-p) (error "No active region"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5805 (let* ((beg (region-beginning))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5806 (end (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5807 l01 c01 l02 c02 l1 c1 l2 c2 ic1 ic2
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5808 region cols
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5809 (rpl (if cut " " nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5810 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5811 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5812 (setq l01 (count-lines (point-min) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5813 c01 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5814 (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5815 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5816 (setq l02 (count-lines (point-min) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5817 c02 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5818 (setq l1 (min l01 l02) l2 (max l01 l02)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5819 c1 (min c01 c02) c2 (max c01 c02))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5820 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5821 (while t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5822 (catch 'nextline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5823 (if (> l1 l2) (throw 'exit t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5824 (goto-line l1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5825 (if (org-at-table-hline-p) (throw 'nextline (setq l1 (1+ l1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5826 (setq cols nil ic1 c1 ic2 c2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5827 (while (< ic1 (1+ ic2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5828 (push (org-table-get-field ic1 rpl) cols)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5829 (setq ic1 (1+ ic1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5830 (push (nreverse cols) region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5831 (setq l1 (1+ l1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5832 (setq org-table-clip (nreverse region))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5833 (if cut (org-table-align))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5834
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5835 (defun org-table-paste-rectangle (&optional arg)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
5836 "Paste a rectangular region into a table.
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5837 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
5838 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
5839 the table is enlarged as needed. The process ignores horizontal separator
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5840 lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5841 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5842 (unless (and org-table-clip (listp org-table-clip))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5843 (error "First cut/copy a region to paste!"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5844 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5845 (let* ((clip org-table-clip)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5846 (line (count-lines (point-min) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5847 (col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5848 (l line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5849 (org-enable-table-editor t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5850 (org-table-automatic-realign nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5851 c cols field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5852 (while (setq cols (pop clip))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5853 (while (org-at-table-hline-p) (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5854 (if (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5855 (progn (end-of-line 0) (org-table-next-field)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5856 (setq c col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5857 (while (setq field (pop cols))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5858 (org-table-goto-column c nil 'force)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5859 (org-table-get-field nil field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5860 (setq c (1+ c)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5861 (beginning-of-line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5862 (goto-line line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5863 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5864 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5865
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5866 (defun org-table-convert ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5867 "Convert from org-mode table to table.el and back.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5868 Obviously, this only works within limits. When an Org-mode table is
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5869 converted to table.el, all horizontal separator lines get lost, because
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5870 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
5871 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
5872 do row or column spanning. Multiline cells will become multiple cells.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5873 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
5874 blindly applies a recipe that works for simple tables."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5875 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5876 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5877 (if (org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5878 ;; convert to Org-mode table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5879 (let ((beg (move-marker (make-marker) (org-table-begin t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5880 (end (move-marker (make-marker) (org-table-end t))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5881 (table-unrecognize-region beg end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5882 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5883 (while (re-search-forward "^\\([ \t]*\\)\\+-.*\n" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5884 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5885 (goto-char beg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5886 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5887 ;; convert to table.el table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5888 (let ((beg (move-marker (make-marker) (org-table-begin)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5889 (end (move-marker (make-marker) (org-table-end))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5890 ;; first, get rid of all horizontal lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5891 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5892 (while (re-search-forward "^\\([ \t]*\\)|-.*\n" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5893 (replace-match ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5894 ;; insert a hline before first
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5895 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5896 (org-table-insert-hline 'above)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5897 ;; insert a hline after each line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5898 (while (progn (beginning-of-line 2) (< (point) end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5899 (org-table-insert-hline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5900 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5901 (setq end (move-marker end (org-table-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5902 ;; replace "+" at beginning and ending of hlines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5903 (while (re-search-forward "^\\([ \t]*\\)|-" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5904 (replace-match "\\1+-"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5905 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5906 (while (re-search-forward "-|[ \t]*$" end t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5907 (replace-match "-+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5908 (goto-char beg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5909
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5910 (defun org-table-wrap-region (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5911 "Wrap several fields in a column like a paragraph.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5912 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
5913 lines, in order to keep the table compact.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5914
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5915 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
5916 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
5917 lines. Generally, this makes the table more compact. A prefix ARG may be
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5918 used to change the number of desired lines. For example, `C-2 C-c C-q'
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5919 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
5920 lines, the remaining lines remain empty. A negative prefix argument reduces
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5921 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
5922 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
5923 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
5924 the table first.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5925
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5926 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
5927 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
5928 line down.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5929
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5930 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
5931 blank, and the content is appended to the field above."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5932 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5933 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5934 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5935 ;; There is a region: fill as a paragraph
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5936 (let ((beg (region-beginning))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5937 nlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5938 (org-table-cut-region)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5939 (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
5940 (error "Region must be limited to single column"))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5941 (setq nlines (if arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5942 (if (< arg 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5943 (+ (length org-table-clip) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5944 arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5945 (length org-table-clip)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5946 (setq org-table-clip
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5947 (mapcar 'list (org-wrap (mapconcat 'car org-table-clip " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5948 nil nlines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5949 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5950 (org-table-paste-rectangle))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5951 ;; No region, split the current field at point
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5952 (if arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5953 ;; combine with field above
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5954 (let ((s (org-table-blank-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5955 (col (org-table-current-column)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5956 (beginning-of-line 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5957 (while (org-at-table-hline-p) (beginning-of-line 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5958 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5959 (skip-chars-forward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5960 (skip-chars-backward " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5961 (insert " " (org-trim s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5962 (org-table-align))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5963 ;; split field
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5964 (when (looking-at "\\([^|]+\\)+|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5965 (let ((s (match-string 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5966 (replace-match " |")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5967 (goto-char (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5968 (org-table-next-row)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5969 (insert (org-trim s) " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5970 (org-table-align))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5971
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5972 (defun org-trim (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5973 "Remove whitespace at beginning and end of string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5974 (if (string-match "^[ \t]+" s) (setq s (replace-match "" t t s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5975 (if (string-match "[ \t]+$" s) (setq s (replace-match "" t t s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5976
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5977 (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
5978 "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
5979 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
5980 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
5981 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
5982 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
5983 many lines, whatever width that takes.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5984 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
5985 (let* ((words (org-split-string string "[ \t\n]+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5986 (maxword (apply 'max (mapcar 'length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5987 (black (apply '+ (mapcar 'length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5988 (total (+ black (length words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5989 w ll)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5990 (cond (width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5991 (org-do-wrap words (max maxword width)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5992 (lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5993 (setq w maxword)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5994 (setq ll (org-do-wrap words maxword))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5995 (if (<= (length ll) lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5996 ll
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5997 (setq ll words)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5998 (while (> (length ll) lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5999 (setq w (1+ w))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6000 (setq ll (org-do-wrap words w)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6001 ll))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6002 (t (error "Cannot wrap this")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6003
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6004
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6005 (defun org-do-wrap (words width)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6006 "Creates lines of maximum width WIDTH (in characters) from word list WORDS."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6007 (let (lines line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6008 (while words
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6009 (setq line (pop words))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6010 (while (and words (< (+ (length line) (length (car words))) width))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6011 (setq line (concat line " " (pop words))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6012 (setq lines (push line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6013 (nreverse lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6014
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6015 ;; FIXME: I think I can make this more efficient
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6016 (defun org-split-string (string &optional separators)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6017 "Splits STRING into substrings at SEPARATORS.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6018 No empty strings are returned if there are matches at the beginning
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6019 and end of string."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6020 (let ((rexp (or separators "[ \f\t\n\r\v]+"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6021 (start 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6022 notfirst
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6023 (list nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6024 (while (and (string-match rexp string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6025 (if (and notfirst
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6026 (= start (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6027 (< start (length string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6028 (1+ start) start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6029 (< (match-beginning 0) (length string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6030 (setq notfirst t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6031 (or (eq (match-beginning 0) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6032 (and (eq (match-beginning 0) (match-end 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6033 (eq (match-beginning 0) start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6034 (setq list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6035 (cons (substring string start (match-beginning 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6036 list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6037 (setq start (match-end 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6038 (or (eq start (length string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6039 (setq list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6040 (cons (substring string start)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6041 list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6042 (nreverse list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6043
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6044 (defun org-table-add-invisible-to-vertical-lines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6045 "Add an `invisible' property to vertical lines of current table."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6046 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6047 (let* ((beg (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6048 (end (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6049 (end1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6050 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6051 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6052 (while (< (point) end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6053 (setq end1 (point-at-eol))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6054 (if (looking-at org-table-dataline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6055 (while (re-search-forward "|" end1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6056 (add-text-properties (1- (point)) (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6057 '(invisible org-table)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6058 (while (re-search-forward "[+|]" end1 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6059 (add-text-properties (1- (point)) (point)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6060 '(invisible org-table))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6061 (beginning-of-line 2)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6062
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6063 (defun org-table-toggle-vline-visibility (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6064 "Toggle the visibility of table vertical lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6065 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
6066 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
6067 visible when ARG is not positive"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6068 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6069 (let ((action (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6070 ((and arg (> (prefix-numeric-value arg) 0)) 'on)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6071 ((and arg (< (prefix-numeric-value arg) 1)) 'off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6072 (t (if (org-in-invisibility-spec-p '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6073 'off
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6074 'on)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6075 (if (eq action 'off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6076 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6077 (org-remove-from-invisibility-spec '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6078 (org-table-map-tables 'org-table-align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6079 (message "Vertical table lines visible")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6080 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6081 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6082 (org-add-to-invisibility-spec '(org-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6083 (org-table-map-tables 'org-table-align)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6084 (message "Vertical table lines invisible"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6085 (redraw-frame (selected-frame))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6086
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6087 (defun org-table-map-tables (function)
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6088 "Apply FUNCTION to the start of all tables in the buffer."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6089 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6090 (save-restriction
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6091 (widen)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6092 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6093 (while (re-search-forward org-table-any-line-regexp nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6094 (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6095 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6096 (if (looking-at org-table-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6097 (save-excursion (funcall function)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6098 (re-search-forward org-table-any-border-regexp nil 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6099
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6100 (defun org-table-sum ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6101 "Sum numbers in region of current table column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6102 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
6103 as kill to be inserted with \\[yank].
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6104
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6105 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
6106 numbers in that rectangle will be summed. If there is no active
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6107 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
6108 column.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6109
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6110 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
6111 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
6112 numbers are added as such."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6113 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6114 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6115 (let (beg end col (timecnt 0) diff h m s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6116 (if (org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6117 (setq beg (region-beginning) end (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6118 (setq col (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6119 (goto-char (org-table-begin))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6120 (unless (re-search-forward "^[ \t]*|[^-]" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6121 (error "No table data"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6122 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6123 (skip-chars-backward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6124 (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6125 (goto-char (org-table-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6126 (unless (re-search-backward "^[ \t]*|[^-]" nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6127 (error "No table data"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6128 (org-table-goto-column col)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6129 (skip-chars-forward "^|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6130 (setq end (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6131 (let* ((l1 (progn (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6132 (+ (if (bolp) 1 0) (count-lines (point-min) (point)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6133 (l2 (progn (goto-char end)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6134 (+ (if (bolp) 1 0) (count-lines (point-min) (point)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6135 (items (if (= l1 l2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6136 (split-string (buffer-substring beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6137 (split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6138 (mapconcat 'identity (extract-rectangle beg end) " "))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6139 (numbers (delq nil (mapcar 'org-table-get-number-for-summing
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6140 items)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6141 (res (apply '+ numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6142 (sres (if (= timecnt 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6143 (format "%g" res)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6144 (setq diff (* 3600 res)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6145 h (floor (/ diff 3600)) diff (mod diff 3600)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6146 m (floor (/ diff 60)) diff (mod diff 60)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6147 s diff)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6148 (format "%d:%02d:%02d" h m s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6149 (kill-new sres)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6150 (message (substitute-command-keys
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6151 (format "Sum of %d items: %-20s (\\[yank] will insert result into buffer)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6152 (length numbers) sres)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6153
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6154 (defun org-table-get-number-for-summing (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6155 (let (n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6156 (if (string-match "^ *|? *" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6157 (setq s (replace-match "" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6158 (if (string-match " *|? *$" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6159 (setq s (replace-match "" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6160 (setq n (string-to-number s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6161 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6162 ((and (string-match "0" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6163 (string-match "\\`[-+ \t0.edED]+\\'" s)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6164 ((string-match "\\`[ \t]+\\'" s) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6165 ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?\\'" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6166 (let ((h (string-to-number (or (match-string 1 s) "0")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6167 (m (string-to-number (or (match-string 2 s) "0")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6168 (s (string-to-number (or (match-string 4 s) "0"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6169 (if (boundp 'timecnt) (setq timecnt (1+ timecnt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6170 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6171 ((equal n 0) nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6172 (t n))))
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 (defvar org-table-current-formula nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6175 (defvar org-table-formula-history nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6176 (defun org-table-get-formula (current)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6177 (if (and current (not (equal "" org-table-current-formula)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6178 org-table-current-formula
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6179 (setq org-table-current-formula
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6180 (read-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6181 "Formula [last]: " "" 'org-table-formula-history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6182 org-table-current-formula))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6183
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6184 (defun org-this-word ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6185 ;; Get the current word
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6186 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6187 (let ((beg (progn (skip-chars-backward "^ \t\n") (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6188 (end (progn (skip-chars-forward "^ \t\n") (point))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6189 (buffer-substring-no-properties beg end))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6190
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6191 (defun org-table-eval-formula (&optional ndown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6192 "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
6193
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6194 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
6195 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
6196 installed in order to use this function.
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 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
6199 result of a formula. While nowhere near the computation options of a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6200 spreadsheet program, this is still very useful. Note that there is no
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6201 automatic updating of a calculated field, nor will the field remember the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6202 formula. The command needs to be applied again after changing input
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6203 fields.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6204
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6205 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
6206 minibuffer. Previously entered formulae are available through the history
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6207 list, and the last used formula is the default, reachable by simply
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6208 pressing RET.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6209
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6210 The formula can be any algebraic expression understood by the calc package.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6211 Before evaluation, variable substitution takes place: \"$\" is replaced by
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6212 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
6213 the current row. Values from a *different* row can *not* be referenced
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6214 here, so the command supports only horizontal computing. The formula can
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6215 contain an optional printf format specifier after a semicolon, to reformat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6216 the result.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6217
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6218 A few examples for formulae:
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6219 $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
6220 $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
6221 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
6222 $;%.1f Reformat current cell to 1 digit after dec.point
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6223 ($3-32)*5/9 degrees F -> C conversion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6224
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6225 When called with a raw C-u prefix, the formula is applied to the current
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6226 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
6227 horizontal line or the end of the table. When the command is called with a
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6228 numeric prefix argument (like M-3 or C-7 or C-u 24), the formula is applied
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6229 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
6230 separator line)."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6231 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6232 (setq ndown (if (equal ndown '(4)) 10000 (prefix-numeric-value ndown)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6233 (require 'calc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6234 (org-table-check-inside-data-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6235 (let* (fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6236 (org-table-automatic-realign nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6237 (down (> ndown 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6238 (formula (org-table-get-formula nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6239 (n0 (org-table-current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6240 n form fmt x ev)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6241 (if (string-match ";" formula)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6242 (let ((tmp (org-split-string formula ";")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6243 (setq formula (car tmp) fmt (nth 1 tmp))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6244 (while (> ndown 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6245 (setq fields (org-split-string
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6246 (concat " " (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6247 (point-at-bol) (point-at-eol))) "|"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6248 (setq ndown (1- ndown))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6249 (setq form (copy-sequence formula))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6250 (while (string-match "\\$\\([0-9]+\\)?" form)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6251 (setq n (if (match-beginning 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6252 (string-to-int (match-string 1 form))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6253 n0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6254 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
6255 (unless x (error "Invalid field specifier \"%s\""
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6256 (match-string 0 form)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6257 (if (equal (string-to-number x) 0) (setq x "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6258 (setq form (replace-match x t t form)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6259 (setq ev (calc-eval (list form) 'num))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6260 (if (listp ev)
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59596
diff changeset
6261 (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
6262 (org-table-blank-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6263 (if fmt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6264 (insert (format fmt (string-to-number ev)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6265 (insert ev))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6266 (if (and down (> ndown 0) (looking-at ".*\n[ \t]*|[^-]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6267 (call-interactively 'org-return)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6268 (setq ndown 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6269 (org-table-align)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6270
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6271 ;;; The orgtbl minor mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6272
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6273 ;; 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
6274 ;; 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
6275
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6276 ;; 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
6277 ;; 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
6278 ;; 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
6279 ;; 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
6280 ;; 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
6281 ;; 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
6282 ;; 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
6283 ;; 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
6284 ;; 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
6285 ;; 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
6286 ;; 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
6287
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6288 ;; 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
6289 ;; 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
6290 ;; 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
6291
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6292 ;; 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
6293 ;; 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
6294 ;; 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
6295 ;; 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
6296 ;; 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
6297 ;; modified self-insert.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6298
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6299 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6300 "Non-nil means, use the optimized table editor version for orgtbl-mode.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6301 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
6302 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
6303 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
6304 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
6305 restored.
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6306
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6307 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
6308 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
6309 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
6310 :group 'org-table
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6311 :type 'boolean)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6312
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6313 (defvar orgtbl-mode nil
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6314 "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
6315 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
6316 (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
6317
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6318 (defvar orgtbl-mode-map (make-sparse-keymap)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6319 "Keymap for orgtbl-mode.")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6320
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6321 ;;;###autoload
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6322 (defun turn-on-orgtbl ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6323 "Unconditionally turn on orgtbl-mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6324 (orgtbl-mode 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6325
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6326 ;;;###autoload
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6327 (defun orgtbl-mode (&optional arg)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6328 "The org-mode table editor as a minor mode for use in other modes."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6329 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6330 (setq orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6331 (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
6332 (if orgtbl-mode
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6333 (progn
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6334 (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
6335 (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
6336 (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
6337 nil 'local)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6338 (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
6339 auto-fill-inhibit-regexp)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6340 (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
6341 (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
6342 (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
6343 "[ \t]*|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6344 (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
6345 (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
6346 (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
6347 (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
6348 (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
6349 (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
6350
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6351 ;; 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
6352 (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
6353 (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
6354 (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
6355
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6356 (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
6357 "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
6358 (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
6359 (list 'if
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6360 '(org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6361 (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
6362 (list 'let '(orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6363 (list 'call-interactively
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6364 (append '(or)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6365 (mapcar (lambda (k)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6366 (list 'key-binding k))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6367 keys)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6368 '('orgtbl-error)))))))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6369
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6370 (defun orgtbl-error ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6371 "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
6372 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6373 (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
6374
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6375 ;; 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
6376 (let ((bindings
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6377 '(([(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
6378 ([(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
6379 ([(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
6380 ([(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
6381 ([(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
6382 ([(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
6383 ([(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
6384 ([(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
6385 ("\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
6386 ("\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
6387 ("\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
6388 ("\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
6389 ([(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
6390 ("\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
6391 ([(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
6392 ([(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
6393 ([(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
6394 ("\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
6395 ("\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
6396 ("\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
6397 ("\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
6398 ("\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
6399 ("\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
6400 elt key fun cmd)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6401 (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
6402 (setq key (car elt)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6403 fun (nth 1 elt)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6404 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
6405 (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
6406
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6407 ;; 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
6408 ;(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
6409 ; (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
6410 ;(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
6411 ; (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
6412 ;(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
6413 ; (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
6414 ;(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
6415 ; (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
6416
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6417 (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
6418 (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
6419 (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
6420 (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
6421 (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
6422 (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
6423 (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
6424 (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
6425
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6426 (when orgtbl-optimized
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6427 ;; 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
6428 ;; some standard editing functions
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6429 (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
6430 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
6431 (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
6432 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
6433 (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
6434 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
6435 (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
6436
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6437 (defun orgtbl-tab ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6438 "Justification and field motion for orgtbl-mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6439 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6440 (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
6441 (org-table-next-field))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6442
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6443 (defun orgtbl-ret ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6444 "Justification and field motion for orgtbl-mode."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6445 (interactive)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6446 (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
6447 (org-table-next-row))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6448
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6449 (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
6450 "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
6451 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
6452 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
6453 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6454 (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
6455 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6456 (looking-at "[^|\n]* +|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6457 (let (org-table-may-need-update (pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6458 (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
6459 (delete-backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6460 (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
6461 (self-insert-command N))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6462 (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
6463 (let (orgtbl-mode)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6464 (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
6465
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6466 (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
6467 "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
6468 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
6469 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
6470 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
6471 reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6472 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6473 (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
6474 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6475 (looking-at ".*?|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6476 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6477 (backward-delete-char N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6478 (skip-chars-forward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6479 (insert " ")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6480 (goto-char (1- pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6481 (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
6482 (delete-backward-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6483
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6484 (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
6485 "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
6486 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
6487 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
6488 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
6489 a reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6490 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6491 (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
6492 (eq N 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6493 (if (looking-at ".*?|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6494 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6495 (replace-match (concat
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6496 (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
6497 " |"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6498 (goto-char pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6499 (delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6500
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6501 (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
6502 '("Tbl"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6503 ["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
6504 ["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
6505 ["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
6506 ["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
6507 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6508 ["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
6509 ["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
6510 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
6511 "--"
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6512 ("Column"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6513 ["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
6514 ["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
6515 ["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
6516 ["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
6517 ("Row"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6518 ["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
6519 ["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
6520 ["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
6521 ["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
6522 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6523 ["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
6524 ("Rectangle"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6525 ["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
6526 ["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
6527 ["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
6528 ["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
6529 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
6530 ["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
6531 ["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
6532 :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
6533 ["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
6534 ))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
6535
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6536 ;;; Exporting
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6537
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6538 (defconst org-level-max 20)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6539
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6540 (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
6541 "Remove all lines from LIST which are before the first headline."
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6542 (let ((orig-list list)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6543 (re (concat "^" outline-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6544 (while (and list
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6545 (not (string-match re (car list))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6546 (pop list))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6547 (or list orig-list)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6548
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6549 (defun org-skip-comments (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6550 "Skip lines starting with \"#\" and subtrees starting with COMMENT."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6551 (let ((re1 (concat "^\\(\\*+\\)[ \t]+" org-comment-string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6552 (re2 "^\\(\\*+\\)[ \t\n\r]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6553 rtn line level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6554 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6555 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6556 ((and (string-match re1 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6557 (setq level (- (match-end 1) (match-beginning 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6558 ;; Beginning of a COMMENT subtree. Skip it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6559 (while (and (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6560 (or (not (string-match re2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6561 (> (- (match-end 1) (match-beginning 1)) level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6562 (setq lines (cons line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6563 ((string-match "^#" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6564 ;; an ordinary comment line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6565 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6566 (t (setq rtn (cons line rtn)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6567 (nreverse rtn)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6568
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6569 ;; ASCII
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6570
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6571 (defconst org-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6572 "Characters for underlining headings in ASCII export.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6573
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6574 (defconst org-html-entities
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6575 '(("nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6576 ("iexcl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6577 ("cent")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6578 ("pound")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6579 ("curren")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6580 ("yen")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6581 ("brvbar")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6582 ("sect")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6583 ("uml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6584 ("copy")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6585 ("ordf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6586 ("laquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6587 ("not")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6588 ("shy")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6589 ("reg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6590 ("macr")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6591 ("deg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6592 ("plusmn")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6593 ("sup2")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6594 ("sup3")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6595 ("acute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6596 ("micro")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6597 ("para")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6598 ("middot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6599 ("odot"."o")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6600 ("star"."*")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6601 ("cedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6602 ("sup1")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6603 ("ordm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6604 ("raquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6605 ("frac14")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6606 ("frac12")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6607 ("frac34")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6608 ("iquest")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6609 ("Agrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6610 ("Aacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6611 ("Acirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6612 ("Atilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6613 ("Auml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6614 ("Aring") ("AA"."&Aring;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6615 ("AElig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6616 ("Ccedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6617 ("Egrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6618 ("Eacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6619 ("Ecirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6620 ("Euml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6621 ("Igrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6622 ("Iacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6623 ("Icirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6624 ("Iuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6625 ("ETH")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6626 ("Ntilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6627 ("Ograve")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6628 ("Oacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6629 ("Ocirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6630 ("Otilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6631 ("Ouml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6632 ("times")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6633 ("Oslash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6634 ("Ugrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6635 ("Uacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6636 ("Ucirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6637 ("Uuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6638 ("Yacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6639 ("THORN")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6640 ("szlig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6641 ("agrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6642 ("aacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6643 ("acirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6644 ("atilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6645 ("auml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6646 ("aring")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6647 ("aelig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6648 ("ccedil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6649 ("egrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6650 ("eacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6651 ("ecirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6652 ("euml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6653 ("igrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6654 ("iacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6655 ("icirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6656 ("iuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6657 ("eth")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6658 ("ntilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6659 ("ograve")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6660 ("oacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6661 ("ocirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6662 ("otilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6663 ("ouml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6664 ("divide")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6665 ("oslash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6666 ("ugrave")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6667 ("uacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6668 ("ucirc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6669 ("uuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6670 ("yacute")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6671 ("thorn")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6672 ("yuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6673 ("fnof")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6674 ("Alpha")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6675 ("Beta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6676 ("Gamma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6677 ("Delta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6678 ("Epsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6679 ("Zeta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6680 ("Eta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6681 ("Theta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6682 ("Iota")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6683 ("Kappa")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6684 ("Lambda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6685 ("Mu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6686 ("Nu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6687 ("Xi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6688 ("Omicron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6689 ("Pi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6690 ("Rho")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6691 ("Sigma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6692 ("Tau")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6693 ("Upsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6694 ("Phi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6695 ("Chi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6696 ("Psi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6697 ("Omega")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6698 ("alpha")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6699 ("beta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6700 ("gamma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6701 ("delta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6702 ("epsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6703 ("varepsilon"."&epsilon;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6704 ("zeta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6705 ("eta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6706 ("theta")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6707 ("iota")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6708 ("kappa")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6709 ("lambda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6710 ("mu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6711 ("nu")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6712 ("xi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6713 ("omicron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6714 ("pi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6715 ("rho")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6716 ("sigmaf") ("varsigma"."&sigmaf;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6717 ("sigma")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6718 ("tau")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6719 ("upsilon")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6720 ("phi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6721 ("chi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6722 ("psi")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6723 ("omega")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6724 ("thetasym") ("vartheta"."&thetasym;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6725 ("upsih")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6726 ("piv")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6727 ("bull") ("bullet"."&bull;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6728 ("hellip") ("dots"."&hellip;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6729 ("prime")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6730 ("Prime")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6731 ("oline")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6732 ("frasl")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6733 ("weierp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6734 ("image")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6735 ("real")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6736 ("trade")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6737 ("alefsym")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6738 ("larr") ("leftarrow"."&larr;") ("gets"."&larr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6739 ("uarr") ("uparrow"."&uarr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6740 ("rarr") ("to"."&rarr;") ("rightarrow"."&rarr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6741 ("darr")("downarrow"."&darr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6742 ("harr") ("leftrightarrow"."&harr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6743 ("crarr") ("hookleftarrow"."&crarr;") ; has round hook, not quite CR
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6744 ("lArr") ("Leftarrow"."&lArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6745 ("uArr") ("Uparrow"."&uArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6746 ("rArr") ("Rightarrow"."&rArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6747 ("dArr") ("Downarrow"."&dArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6748 ("hArr") ("Leftrightarrow"."&hArr;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6749 ("forall")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6750 ("part") ("partial"."&part;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6751 ("exist") ("exists"."&exist;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6752 ("empty") ("emptyset"."&empty;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6753 ("nabla")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6754 ("isin") ("in"."&isin;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6755 ("notin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6756 ("ni")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6757 ("prod")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6758 ("sum")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6759 ("minus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6760 ("lowast") ("ast"."&lowast;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6761 ("radic")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6762 ("prop") ("proptp"."&prop;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6763 ("infin") ("infty"."&infin;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6764 ("ang") ("angle"."&ang;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6765 ("and") ("vee"."&and;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6766 ("or") ("wedge"."&or;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6767 ("cap")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6768 ("cup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6769 ("int")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6770 ("there4")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6771 ("sim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6772 ("cong") ("simeq"."&cong;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6773 ("asymp")("approx"."&asymp;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6774 ("ne") ("neq"."&ne;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6775 ("equiv")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6776 ("le")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6777 ("ge")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6778 ("sub") ("subset"."&sub;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6779 ("sup") ("supset"."&sup;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6780 ("nsub")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6781 ("sube")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6782 ("supe")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6783 ("oplus")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6784 ("otimes")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6785 ("perp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6786 ("sdot") ("cdot"."&sdot;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6787 ("lceil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6788 ("rceil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6789 ("lfloor")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6790 ("rfloor")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6791 ("lang")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6792 ("rang")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6793 ("loz") ("Diamond"."&loz;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6794 ("spades") ("spadesuit"."&spades;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6795 ("clubs") ("clubsuit"."&clubs;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6796 ("hearts") ("diamondsuit"."&hearts;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6797 ("diams") ("diamondsuit"."&diams;")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6798 ("quot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6799 ("amp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6800 ("lt")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6801 ("gt")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6802 ("OElig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6803 ("oelig")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6804 ("Scaron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6805 ("scaron")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6806 ("Yuml")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6807 ("circ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6808 ("tilde")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6809 ("ensp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6810 ("emsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6811 ("thinsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6812 ("zwnj")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6813 ("zwj")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6814 ("lrm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6815 ("rlm")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6816 ("ndash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6817 ("mdash")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6818 ("lsquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6819 ("rsquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6820 ("sbquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6821 ("ldquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6822 ("rdquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6823 ("bdquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6824 ("dagger")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6825 ("Dagger")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6826 ("permil")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6827 ("lsaquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6828 ("rsaquo")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6829 ("euro")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6830
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6831 ("arccos"."arccos")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6832 ("arcsin"."arcsin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6833 ("arctan"."arctan")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6834 ("arg"."arg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6835 ("cos"."cos")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6836 ("cosh"."cosh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6837 ("cot"."cot")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6838 ("coth"."coth")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6839 ("csc"."csc")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6840 ("deg"."deg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6841 ("det"."det")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6842 ("dim"."dim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6843 ("exp"."exp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6844 ("gcd"."gcd")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6845 ("hom"."hom")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6846 ("inf"."inf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6847 ("ker"."ker")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6848 ("lg"."lg")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6849 ("lim"."lim")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6850 ("liminf"."liminf")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6851 ("limsup"."limsup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6852 ("ln"."ln")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6853 ("log"."log")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6854 ("max"."max")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6855 ("min"."min")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6856 ("Pr"."Pr")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6857 ("sec"."sec")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6858 ("sin"."sin")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6859 ("sinh"."sinh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6860 ("sup"."sup")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6861 ("tan"."tan")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6862 ("tanh"."tanh")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6863 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6864 "Entities for TeX->HTML translation.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6865 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
6866 \"&ent;\". An entry can also be a dotted pair like (\"ent\".\"&other;\").
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6867 In that case, \"\\ent\" will be translated to \"&other;\".
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6868 The list contains HTML entities for Latin-1, Greek and other symbols.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6869 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
6870 translations.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6871
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6872 (defun org-export-as-ascii (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6873 "Export the outline as a pretty ASCII file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6874 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6875 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6876 underlined headlines. The default is 3."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6877 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6878 (setq-default org-todo-line-regexp org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6879 (let* ((region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6880 (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6881 (if (org-region-active-p) (region-beginning) (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6882 (if (org-region-active-p) (region-end) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6883 (lines (org-export-find-first-heading-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6884 (org-skip-comments (org-split-string region "[\r\n]"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6885 (org-startup-with-deadline-check nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6886 (level 0) line txt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6887 (umax nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6888 (case-fold-search nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6889 (filename (concat (file-name-sans-extension (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6890 ".txt"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6891 (buffer (find-file-noselect filename))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6892 (levels-open (make-vector org-level-max nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6893 (date (format-time-string "%Y/%m/%d" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6894 (time (format-time-string "%X" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6895 (author user-full-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6896 (title (buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6897 (options nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6898 (email user-mail-address)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6899 (language org-export-default-language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6900 (text nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6901 (last-level 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6902 (todo nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6903 (lang-words nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6904
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6905 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6906
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6907 (find-file-noselect filename)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6908
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6909 ;; Search for the export key lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6910 (org-parse-key-lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6911
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6912 (setq lang-words (or (assoc language org-export-language-setup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6913 (assoc "en" org-export-language-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6914 (if org-export-ascii-show-new-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6915 (switch-to-buffer-other-window buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6916 (set-buffer buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6917 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6918 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6919 (if options (org-parse-export-options options))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6920 (setq umax (if arg (prefix-numeric-value arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6921 org-export-headline-levels))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6922
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6923 ;; File header
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6924 (if title (org-insert-centered title ?=))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6925 (insert "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6926 (if (or author email)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6927 (insert (concat (nth 1 lang-words) ": " (or author "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6928 (if email (concat " <" email ">") "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6929 "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6930 (if (and date time)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6931 (insert (concat (nth 2 lang-words) ": " date " " time "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6932 (if text (insert (concat (org-html-expand-for-ascii text) "\n\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6933
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6934 (insert "\n\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6935
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6936 (if org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6937 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6938 (insert (nth 3 lang-words) "\n"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6939 (make-string (length (nth 3 lang-words)) ?=) "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6940 (mapcar '(lambda (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6941 (if (string-match org-todo-line-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6942 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6943 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6944 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6945 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6946 txt (match-string 3 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6947 todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6948 (or (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6949 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6950 org-done-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6951 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6952 (and (= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6953 (org-search-todo-below
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6954 line lines level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6955 (setq txt (org-html-expand-for-ascii txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6956
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6957 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6958 (setq txt (concat (org-section-number level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6959 " " txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6960 (if (<= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6961 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6962 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6963 (make-string (* (1- level) 4) ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6964 (format (if todo "%s (*)\n" "%s\n") txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6965 (setq last-level level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6966 ))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6967 lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6968
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6969 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6970 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6971 ;; Remove the quoted HTML tags.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6972 (setq line (org-html-expand-for-ascii line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6973 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6974 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6975 ;; a Headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6976 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6977 txt (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6978 (org-ascii-level-start level txt umax))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6979 (t (insert line "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6980 (normal-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6981 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6982 (goto-char (point-min))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6983
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6984 (defun org-search-todo-below (line lines level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6985 "Search the subtree below LINE for any TODO entries."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6986 (let ((rest (cdr (memq line lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6987 (re org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6988 line lv todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6989 (catch 'exit
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6990 (while (setq line (pop rest))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6991 (if (string-match re line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6992 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6993 (setq lv (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6994 todo (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6995 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6996 org-done-string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6997 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6998 (if (<= lv level) (throw 'exit nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6999 (if todo (throw 'exit t))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7000
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7001 ;; 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
7002 ;; FIXME: Can I implement *bold*,/italic/ and _underline_ for ASCII export?
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7003 (defun org-html-expand-for-ascii (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7004 "Handle quoted HTML for ASCII export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7005 (if org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7006 (while (string-match "@<[^<>\n]*>" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7007 ;; We just remove the tags for now.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7008 (setq line (replace-match "" nil nil line))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7009 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7010
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7011 (defun org-insert-centered (s &optional underline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7012 "Insert the string S centered and underline it with character UNDERLINE."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7013 (let ((ind (max (/ (- 80 (length s)) 2) 0)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7014 (insert (make-string ind ?\ ) s "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7015 (if underline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7016 (insert (make-string ind ?\ )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7017 (make-string (length s) underline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7018 "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7019
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7020 (defun org-ascii-level-start (level title umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7021 "Insert a new level in ASCII export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7022 (let (char)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7023 (if (> level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7024 (insert (make-string (* 2 (- level umax 1)) ?\ ) "* " title "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7025 (if (or (not (equal (char-before) ?\n))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7026 (not (equal (char-before (1- (point))) ?\n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7027 (insert "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7028 (setq char (nth (- umax level) (reverse org-ascii-underline)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7029 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7030 (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
7031 (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
7032
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7033 (defun org-export-copy-visible (&optional arg)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7034 "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
7035 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
7036 and all options lines."
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7037 (interactive "P")
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7038 (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
7039 ".txt"))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7040 (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
7041 (ore (concat
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7042 (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
7043 '("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
7044 "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
7045 (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
7046 s e)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7047 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7048 (set-buffer buffer)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7049 (erase-buffer)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7050 (text-mode))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7051 (save-excursion
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7052 (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
7053 (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
7054 (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
7055 (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
7056 (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
7057 (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
7058 (newline)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7059 (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
7060 (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
7061 (replace-match ""))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7062 (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
7063 (replace-match ""))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7064 (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
7065
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7066 (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
7067 (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
7068 (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
7069 (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
7070 (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
7071 s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7072 (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
7073 (point)))
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7074 (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
7075 (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
7076 (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
7077 (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
7078 (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
7079 s)
ac45ed541a16 * org.el (org-agenda-phases-of-moon, org-agenda-sunrise-sunset)
Carsten Dominik <dominik@science.uva.nl>
parents: 60918
diff changeset
7080 (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
7081 (point)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7082
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7083 ;; HTML
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7084
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7085 (defun org-get-current-options ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7086 "Return a string with current options as keyword options.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7087 Does include HTML export options as well as TODO and CATEGORY stuff."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7088 (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7089 "#+TITLE: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7090 #+AUTHOR: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7091 #+EMAIL: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7092 #+LANGUAGE: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7093 #+TEXT: Some descriptive text to be emitted. Several lines OK.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7094 #+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
7095 #+CATEGORY: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7096 #+SEQ_TODO: %s
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7097 #+TYP_TODO: %s
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7098 #+STARTUP: %s %s
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7099 "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7100 (buffer-name) (user-full-name) user-mail-address org-export-default-language
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7101 org-export-headline-levels
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7102 org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7103 org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7104 org-export-preserve-breaks
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7105 org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7106 org-export-with-fixed-width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7107 org-export-with-tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7108 org-export-with-sub-superscripts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7109 org-export-with-emphasize
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7110 org-export-with-TeX-macros
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7111 (file-name-nondirectory (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7112 (if (equal org-todo-interpretation 'sequence)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7113 (mapconcat 'identity org-todo-keywords " ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7114 "TODO FEEDBACK VERIFY DONE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7115 (if (equal org-todo-interpretation 'type)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7116 (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
7117 "Me Jason Marie DONE")
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7118 (cdr (assoc org-startup-folded
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
7119 '((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
7120 (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
7121 ))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7122
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7123 (defun org-insert-export-options-template ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7124 "Insert into the buffer a template with information for exporting."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7125 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7126 (if (not (bolp)) (newline))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7127 (let ((s (org-get-current-options)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7128 (and (string-match "#\\+CATEGORY" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7129 (setq s (substring s 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7130 (insert s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7131
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7132 (defun org-toggle-fixed-width-section (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7133 "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
7134 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
7135 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
7136 vertical bar \"|\", then the command removes the bar from all lines in
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7137 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
7138 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
7139
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7140 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
7141 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7142 (let* ((cc 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7143 (regionp (org-region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7144 (beg (if regionp (region-beginning) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7145 (end (if regionp (region-end)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7146 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7147 (re "[ \t]*\\(:\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7148 off)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7149 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7150 (goto-char beg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7151 (setq cc (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7152 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7153 (setq off (looking-at re))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7154 (while (> nlines 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7155 (setq nlines (1- nlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7156 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7157 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7158 (arg
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7159 (move-to-column cc t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7160 (insert ":\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7161 (forward-line -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7162 ((and off (looking-at re))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7163 (replace-match "" t t nil 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7164 ((not off) (move-to-column cc t) (insert ":")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7165 (forward-line 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7166
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7167 (defun org-export-as-html-and-open (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7168 "Export the outline as HTML and immediately open it with a browser.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7169 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7170 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7171 headlines. The default is 3. Lower levels will become bulleted lists."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7172 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7173 (org-export-as-html arg 'hidden)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7174 (org-open-file (buffer-file-name)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7175
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7176 (defun org-export-as-html-batch ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7177 "Call org-export-as-html, may be used in batch processing as
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7178 emacs --batch
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7179 --load=$HOME/lib/emacs/org.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7180 --eval \"(setq org-export-headline-levels 2)\"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7181 --visit=MyFile --funcall org-export-as-html-batch"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7182 (org-export-as-html org-export-headline-levels 'hidden))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7183
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7184 (defun org-export-as-html (arg &optional hidden)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7185 "Export the outline as a pretty HTML file.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7186 If there is an active region, export only the region.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7187 The prefix ARG specifies how many levels of the outline should become
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7188 headlines. The default is 3. Lower levels will become bulleted lists."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7189 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7190 (setq-default org-todo-line-regexp org-todo-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7191 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7192 (setq-default org-done-string org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7193 (let* ((region-p (org-region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7194 (region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7195 (buffer-substring
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7196 (if region-p (region-beginning) (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7197 (if region-p (region-end) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7198 (all_lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7199 (org-skip-comments (org-split-string region "[\r\n]")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7200 (lines (org-export-find-first-heading-line all_lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7201 (level 0) (line "") (origline "") txt todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7202 (last-level 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7203 (umax nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7204 (filename (concat (file-name-sans-extension (buffer-file-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7205 ".html"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7206 (buffer (find-file-noselect filename))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7207 (levels-open (make-vector org-level-max nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7208 (date (format-time-string "%Y/%m/%d" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7209 (time (format-time-string "%X" (current-time)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7210 (author user-full-name)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7211 (title (buffer-name))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7212 (options nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7213 (email user-mail-address)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7214 (language org-export-default-language)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7215 (text nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7216 (lang-words nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7217 (head-count 0) cnt
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7218 table-open type
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7219 table-buffer table-orig-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7220 )
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7221 (message "Exporting...")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7222
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7223 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7224
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7225 ;; Search for the export key lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7226 (org-parse-key-lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7227 (setq lang-words (or (assoc language org-export-language-setup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7228 (assoc "en" org-export-language-setup)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7229
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7230 ;; Switch to the output buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7231 (if (or hidden (not org-export-html-show-new-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7232 (set-buffer buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7233 (switch-to-buffer-other-window buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7234 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7235 (fundamental-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7236 (let ((case-fold-search nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7237 (if options (org-parse-export-options options))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7238 (setq umax (if arg (prefix-numeric-value arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7239 org-export-headline-levels))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7240
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7241 ;; File header
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7242 (insert (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7243 "<html lang=\"%s\"><head>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7244 <title>%s</title>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7245 <meta http-equiv=\"Content-Type\" content=\"text/html\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7246 <meta name=generator content=\"Org-mode\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7247 <meta name=generated content=\"%s %s\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7248 <meta name=author content=\"%s\">
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7249 </head><body>
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7250 "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7251 language (org-html-expand title) date time author))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7252 (if title (insert (concat "<H1 align=\"center\">"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7253 (org-html-expand title) "</H1>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7254 (if author (insert (concat (nth 1 lang-words) ": " author "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7255 (if email (insert (concat "<a href=\"mailto:" email "\">&lt;"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7256 email "&gt;</a>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7257 (if (or author email) (insert "<br>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7258 (if (and date time) (insert (concat (nth 2 lang-words) ": "
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7259 date " " time "<br>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7260 (if text (insert (concat "<p>\n" (org-html-expand text))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7261 (if org-export-with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7262 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7263 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7264 (insert "<ul>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7265 (mapcar '(lambda (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7266 (if (string-match org-todo-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7267 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7268 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7269 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7270 txt (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7271 (org-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7272 (match-string 3 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7273 todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7274 (or (and (match-beginning 2)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7275 (not (equal (match-string 2 line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7276 org-done-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7277 ; TODO, not DONE
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7278 (and (= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7279 (org-search-todo-below
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7280 line lines level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7281 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7282 (setq txt (concat (org-section-number level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7283 " " txt)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7284 (if (<= level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7285 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7286 (setq head-count (+ head-count 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7287 (if (> level last-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7288 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7289 (setq cnt (- level last-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7290 (while (>= (setq cnt (1- cnt)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7291 (insert "<ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7292 (insert "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7293 (if (< level last-level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7294 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7295 (setq cnt (- last-level level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7296 (while (>= (setq cnt (1- cnt)) 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7297 (insert "</ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7298 (insert "\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7299 (insert
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7300 (format
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7301 (if todo
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7302 "<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
7303 "<li><a href=\"#sec-%d\">%s</a></li>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7304 head-count txt))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7305 (setq last-level level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7306 ))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7307 lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7308 (while (> last-level 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7309 (setq last-level (1- last-level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7310 (insert "</ul>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7311 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7312 (setq head-count 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7313 (org-init-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7314
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7315 (while (setq line (pop lines) origline line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7316 ;; replace "<" and ">" by "&lt;" and "&gt;"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7317 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7318 (setq line (org-html-expand line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7319
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7320 ;; Verbatim lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7321 (if (and org-export-with-fixed-width
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7322 (string-match "^[ \t]*:\\(.*\\)" line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7323 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7324 (let ((l (match-string 1 line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7325 (while (string-match " " l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7326 (setq l (replace-match "&nbsp;" t t l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7327 (insert "\n<span style='font-family:Courier'>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7328 l "</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7329 (if (and lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7330 (not (string-match "^[ \t]+\\(:.*\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7331 (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7332 "<br>\n" "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7333
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7334 (when (string-match org-link-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7335 (setq type (match-string 1 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7336 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7337 ((member type '("http" "https" "ftp" "mailto" "news"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7338 ;; standard URL
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7339 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7340 "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7341 nil nil line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7342 ((string= type "file")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7343 ;; FILE link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7344
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7345 (let* ((filename (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7346 (file-is-image-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7347 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7348 (string-match (org-image-file-name-regexp) filename))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7349 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7350 (if (and org-export-html-inline-images
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7351 file-is-image-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7352 "<img src=\"\\2\"/>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7353 "<a href=\"\\2\">\\1:\\2</a>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7354 nil nil line))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7355
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7356 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7357 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7358 "<i>&lt;\\1:\\2&gt;</i>" nil nil line)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7359
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7360 ;; TODO items
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7361 (if (and (string-match org-todo-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7362 (match-beginning 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7363 (if (equal (match-string 2 line) org-done-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7364 (setq line (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7365 "<span style='color:green'>\\2</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7366 nil nil line 2))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7367 (setq line (replace-match "<span style='color:red'>\\2</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7368 nil nil line 2))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7369
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7370 ;; DEADLINES
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7371 (if (string-match org-deadline-line-regexp line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7372 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7373 (if (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7374 (string-match "<a href"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7375 (substring line 0 (match-beginning 0))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7376 nil ; Don't do the replacement - it is inside a link
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7377 (setq line (replace-match "<span style='color:red'>\\&</span>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7378 nil nil line 1)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7379
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7380 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7381 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7382 ;; This is a headline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7383 (setq level (- (match-end 1) (match-beginning 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7384 txt (match-string 2 line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7385 (if (<= level umax) (setq head-count (+ head-count 1)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7386 (org-html-level-start level txt umax
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7387 (and org-export-with-toc (<= level umax))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7388 head-count))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7389
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7390 ((and org-export-with-tables
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7391 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7392 (if (not table-open)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7393 ;; New table starts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7394 (setq table-open t table-buffer nil table-orig-buffer nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7395 ;; Accumulate lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7396 (setq table-buffer (cons line table-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7397 table-orig-buffer (cons origline table-orig-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7398 (when (or (not lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7399 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7400 (car lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7401 (setq table-open nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7402 table-buffer (nreverse table-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7403 table-orig-buffer (nreverse table-orig-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7404 (insert (org-format-table-html table-buffer table-orig-buffer))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7405 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7406 ;; Normal lines
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7407 ;; Lines starting with "-", and empty lines make new paragraph.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7408 (if (string-match "^ *-\\|^[ \t]*$" line) (insert "<p>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7409 (insert line (if org-export-preserve-breaks "<br>\n" "\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7410 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7411 (if org-export-html-with-timestamp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7412 (insert org-export-html-html-helper-timestamp))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7413 (insert "</body>\n</html>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7414 (normal-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7415 (save-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7416 (goto-char (point-min)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7417
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7418 (defun org-format-table-html (lines olines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7419 "Find out which HTML converter to use and return the HTML code."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7420 (if (string-match "^[ \t]*|" (car lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7421 ;; A normal org table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7422 (org-format-org-table-html lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7423 ;; Table made by table.el - test for spanning
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7424 (let* ((hlines (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7425 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7426 (if (string-match "^[ \t]*\\+-" x) x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7427 nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7428 lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7429 (first (car hlines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7430 (ll (and (string-match "\\S-+" first)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7431 (match-string 0 first)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7432 (re (concat "^[ \t]*" (regexp-quote ll)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7433 (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7434 hlines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7435 (if (and (not spanning)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7436 (not org-export-prefer-native-exporter-for-tables))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7437 ;; We can use my own converter with HTML conversions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7438 (org-format-table-table-html lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7439 ;; 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
7440 (org-format-table-table-html-using-table-generate-source olines)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7441
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7442 (defun org-format-org-table-html (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7443 "Format a table into html."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7444 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7445 (setq lines (nreverse lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7446 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7447 (setq lines (nreverse lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7448 (let ((head (and org-export-highlight-first-table-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7449 (delq nil (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7450 (lambda (x) (string-match "^[ \t]*|-" x))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7451 lines))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7452 lastline line fields html empty)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7453 (setq html (concat org-export-html-table-tag "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7454 (while (setq lastline line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7455 line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7456 (setq empty "&nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7457 (catch 'next-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7458 (if (string-match "^[ \t]*|-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7459 (if lastline
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7460 ;; A hline: simulate an empty table row instead.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7461 (setq line (org-fake-empty-table-line lastline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7462 head nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7463 empty "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7464 ;; Ignore this line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7465 (throw 'next-line t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7466 ;; Break the line into fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7467 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7468 (setq html (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7469 html
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7470 "<tr>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7471 (mapconcat (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7472 (if (equal x "") (setq x empty))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7473 (if head
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7474 (concat "<th>" x "</th>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7475 (concat "<td valign=\"top\">" x "</td>")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7476 fields "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7477 "</tr>\n"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7478 (setq html (concat html "</table>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7479 html))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7480
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7481 (defun org-fake-empty-table-line (line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7482 "Replace everything except \"|\" with spaces."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7483 (let ((i (length line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7484 (newstr (copy-sequence line)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7485 (while (> i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7486 (setq i (1- i))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7487 (if (not (eq (aref newstr i) ?|))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7488 (aset newstr i ?\ )))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7489 newstr))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7490
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7491 (defun org-format-table-table-html (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7492 "Format a table generated by table.el into html.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7493 This conversion does *not* use `table-generate-source' from table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7494 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
7495 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
7496 (let (line field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7497 (head org-export-highlight-first-table-line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7498 fields html empty)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7499 (setq html (concat org-export-html-table-tag "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7500 (while (setq line (pop lines))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7501 (setq empty "&nbsp")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7502 (catch 'next-line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7503 (if (string-match "^[ \t]*\\+-" line)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7504 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7505 (if field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7506 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7507 (setq html (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7508 html
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7509 "<tr>"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7510 (mapconcat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7511 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7512 (if (equal x "") (setq x empty))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7513 (if head
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7514 (concat "<th valign=\"top\">" x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7515 "</th>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7516 (concat "<td valign=\"top\">" x
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7517 "</td>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7518 field-buffer "\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7519 "</tr>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7520 (setq head nil)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7521 (setq field-buffer nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7522 ;; Ignore this line
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7523 (throw 'next-line t)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7524 ;; Break the line into fields and store the fields
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7525 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7526 (if field-buffer
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7527 (setq field-buffer (mapcar
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7528 (lambda (x)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7529 (concat x "<br>" (pop fields)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7530 field-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7531 (setq field-buffer fields))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7532 (setq html (concat html "</table>\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7533 html))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7534
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7535 (defun org-format-table-table-html-using-table-generate-source (lines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7536 "Format a table into html, using `table-generate-source' from table.el.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7537 This has the advantage that cell- or row-spanning is allowed.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7538 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
7539 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7540 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7541 (set-buffer (get-buffer-create " org-tmp1 "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7542 (erase-buffer)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7543 (insert (mapconcat 'identity lines "\n"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7544 (goto-char (point-min))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7545 (if (not (re-search-forward "|[^+]" nil t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7546 (error "Error processing table."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7547 (table-recognize-table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7548 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7549 (set-buffer (get-buffer-create " org-tmp2 "))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7550 (erase-buffer))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7551 (table-generate-source 'html " org-tmp2 ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7552 (set-buffer " org-tmp2 ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7553 (buffer-substring (point-min) (point-max))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7554
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7555 (defun org-html-expand (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7556 "Prepare STRING for HTML export. Applies all active conversions."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7557 ;; 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
7558 ;; only before the start of the link.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7559 (let* ((m (string-match org-link-regexp string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7560 (s (if m (substring string 0 m) string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7561 (r (if m (substring string m) "")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7562 ;; convert < to &lt; and > to &gt;
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7563 (while (string-match "<" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7564 (setq s (replace-match "&lt;" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7565 (while (string-match ">" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7566 (setq s (replace-match "&gt;" nil nil s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7567 (if org-export-html-expand
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7568 (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7569 (setq s (replace-match "<\\1>" nil nil s))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7570 (if org-export-with-emphasize
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7571 (setq s (org-export-html-convert-emphasize s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7572 (if org-export-with-sub-superscripts
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7573 (setq s (org-export-html-convert-sub-super s)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7574 (if org-export-with-TeX-macros
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7575 (let ((start 0) wd ass)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7576 (while (setq start (string-match "\\\\\\([a-zA-Z]+\\)" s start))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7577 (setq wd (match-string 1 s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7578 (if (setq ass (assoc wd org-html-entities))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7579 (setq s (replace-match (or (cdr ass)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7580 (concat "&" (car ass) ";"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7581 t t s))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7582 (setq start (+ start (length wd)))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7583 (concat s r)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7584
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7585 (defun org-create-multibrace-regexp (left right n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7586 "Create a regular expression which will match a balanced sexp.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7587 Opening delimiter is LEFT, and closing delimiter is RIGHT, both given
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7588 as single character strings.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7589 The regexp returned will match the entire expression including the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7590 delimiters. It will also define a single group which contains the
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7591 match except for the outermost delimiters. The maximum depth of
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7592 stacked delimiters is N. Escaping delimiters is not possible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7593 (let* ((nothing (concat "[^" "\\" left "\\" right "]*?"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7594 (or "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7595 (re nothing)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7596 (next (concat "\\(?:" nothing left nothing right "\\)+" nothing)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7597 (while (> n 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7598 (setq n (1- n)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7599 re (concat re or next)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7600 next (concat "\\(?:" nothing left next right "\\)+" nothing)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7601 (concat left "\\(" re "\\)" right)))
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 (defvar org-match-substring-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7604 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7605 "\\([^\\]\\)\\([_^]\\)\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7606 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7607 "\\|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7608 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7609 "\\|"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7610 "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7611 "The regular expression matching a sub- or superscript.")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7612
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7613 (defun org-export-html-convert-sub-super (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7614 "Convert sub- and superscripts in STRING to HTML."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7615 (let (key c)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7616 (while (string-match org-match-substring-regexp string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7617 (setq key (if (string= (match-string 2 string) "_") "sub" "sup"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7618 (setq c (or (match-string 8 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7619 (match-string 6 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7620 (match-string 5 string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7621 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7622 (concat (match-string 1 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7623 "<" key ">" c "</" key ">")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7624 t t string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7625 (while (string-match "\\\\\\([_^]\\)" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7626 (setq string (replace-match (match-string 1 string) t t string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7627 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7628
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7629 (defun org-export-html-convert-emphasize (string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7630 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7631 "\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7632 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7633 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7634 (concat "<b>" (match-string 3 string) "</b>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7635 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7636 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7637 "\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7638 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7639 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7640 (concat "<i>" (match-string 3 string) "</i>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7641 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7642 (while (string-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7643 "\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7644 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7645 (setq string (replace-match
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7646 (concat "<u>" (match-string 3 string) "</u>")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7647 t t string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7648 string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7649
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7650 (defun org-parse-key-lines ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7651 "Find the special key lines with the information for exporters."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7652 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7653 (goto-char 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7654 (let ((re (org-make-options-regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7655 '("TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7656 key)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7657 (while (re-search-forward re nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7658 (setq key (match-string 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7659 (cond ((string-equal key "TITLE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7660 (setq title (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7661 ((string-equal key "AUTHOR")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7662 (setq author (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7663 ((string-equal key "EMAIL")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7664 (setq email (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7665 ((string-equal key "LANGUAGE")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7666 (setq language (match-string 2)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7667 ((string-equal key "TEXT")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7668 (setq text (concat text "\n" (match-string 2))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7669 ((string-equal key "OPTIONS")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7670 (setq options (match-string 2))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7671
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7672 (defun org-parse-export-options (s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7673 "Parse the export options line."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7674 (let ((op '(("H" . org-export-headline-levels)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7675 ("num" . org-export-with-section-numbers)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7676 ("toc" . org-export-with-toc)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7677 ("\\n" . org-export-preserve-breaks)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7678 ("@" . org-export-html-expand)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7679 (":" . org-export-with-fixed-width)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7680 ("|" . org-export-with-tables)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7681 ("^" . org-export-with-sub-superscripts)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7682 ("*" . org-export-with-emphasize)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7683 ("TeX" . org-export-with-TeX-macros)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7684 o)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7685 (while (setq o (pop op))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7686 (if (string-match (concat (regexp-quote (car o)) ":\\([^ \t\n\r;,.]*\\)")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7687 s)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7688 (set (make-local-variable (cdr o))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7689 (car (read-from-string (match-string 1 s))))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7690
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7691 (defun org-html-level-start (level title umax with-toc head-count)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7692 "Insert a new level in HTML export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7693 (let ((l (1+ (max level umax))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7694 (while (<= l org-level-max)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7695 (if (aref levels-open (1- l))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7696 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7697 (org-html-level-close l)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7698 (aset levels-open (1- l) nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7699 (setq l (1+ l)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7700 (if (> level umax)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7701 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7702 (if (aref levels-open (1- level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7703 (insert "<li>" title "<p>\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7704 (aset levels-open (1- level) t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7705 (insert "<ul><li>" title "<p>\n")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7706 (if org-export-with-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7707 (setq title (concat (org-section-number level) " " title)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7708 (setq level (+ level 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7709 (if with-toc
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7710 (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
7711 level head-count title level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7712 (insert (format "\n<H%d>%s</H%d>\n" level title level))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7713
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7714 (defun org-html-level-close (level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7715 "Terminate one level in HTML export."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7716 (insert "</ul>"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7717
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 ;; Variable holding the vector with section numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7720 (defvar org-section-numbers (make-vector org-level-max 0))
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-init-section-numbers ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7723 "Initialize the vector for the section numbers."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7724 (let* ((level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7725 (numbers (nreverse (org-split-string "" "\\.")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7726 (depth (1- (length org-section-numbers)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7727 (i depth) number-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7728 (while (>= i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7729 (if (> i level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7730 (aset org-section-numbers i 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7731 (setq number-string (or (car numbers) "0"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7732 (if (string-match "\\`[A-Z]\\'" number-string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7733 (aset org-section-numbers i
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7734 (- (string-to-char number-string) ?A -1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7735 (aset org-section-numbers i (string-to-int number-string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7736 (pop numbers))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7737 (setq i (1- i)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7738
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7739 (defun org-section-number (&optional level)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7740 "Return a string with the current section number.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7741 When LEVEL is non-nil, increase section numbers on that level."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7742 (let* ((depth (1- (length org-section-numbers))) idx n (string ""))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7743 (when level
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7744 (when (> level -1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7745 (aset org-section-numbers
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7746 level (1+ (aref org-section-numbers level))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7747 (setq idx (1+ level))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7748 (while (<= idx depth)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7749 (if (not (= idx 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7750 (aset org-section-numbers idx 0))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7751 (setq idx (1+ idx))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7752 (setq idx 0)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7753 (while (<= idx depth)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7754 (setq n (aref org-section-numbers idx))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7755 (setq string (concat string (if (not (string= string "")) "." "")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7756 (int-to-string n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7757 (setq idx (1+ idx)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7758 (save-match-data
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7759 (if (string-match "\\`\\([@0]\\.\\)+" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7760 (setq string (replace-match "" nil nil string)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7761 (if (string-match "\\(\\.0\\)+\\'" string)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7762 (setq string (replace-match "" nil nil string))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7763 string))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7764
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7765
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7766 ;;; Key bindings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7767
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7768 ;; - Bindings in Org-mode map are currently
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7769 ;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7770 ;; abcd fgh j lmnopqrstuvwxyz ? # -+ /= [] ; |,.<> \t necessary bindings
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7771 ;; e (?) useful from outline-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7772 ;; i k @ expendable from outline-mode
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7773 ;; 0123456789 ! $%^& * ()_{} " ~`' free
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7774
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7775 (define-key org-mode-map [(tab)] 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7776 (define-key org-mode-map "\C-i" 'org-cycle)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7777 (define-key org-mode-map [(meta tab)] 'org-complete)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7778 (define-key org-mode-map "\M-\C-i" 'org-complete)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7779 (define-key org-mode-map [(meta shift left)] 'org-shiftmetaleft)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7780 (define-key org-mode-map [(meta left)] 'org-metaleft)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7781 (define-key org-mode-map [(meta shift right)] 'org-shiftmetaright)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7782 (define-key org-mode-map [(meta shift up)] 'org-shiftmetaup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7783 (define-key org-mode-map [(meta shift down)] 'org-shiftmetadown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7784 (define-key org-mode-map [(meta right)] 'org-metaright)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7785 (define-key org-mode-map [(meta up)] 'org-metaup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7786 (define-key org-mode-map [(meta down)] 'org-metadown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7787 ;(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
7788 ;(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
7789 ;(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
7790 (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
7791 (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
7792 (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
7793 (define-key org-mode-map "\C-c\C-j" 'org-goto)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7794 (define-key org-mode-map "\C-c\C-t" 'org-todo)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7795 (define-key org-mode-map "\C-c\C-s" 'org-schedule)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7796 (define-key org-mode-map "\C-c\C-d" 'org-deadline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7797 (define-key org-mode-map "\C-c;" 'org-toggle-comment)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7798 (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
7799 (define-key org-mode-map "\C-c\C-w" 'org-check-deadlines)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7800 (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7801 (define-key org-mode-map "\C-c\C-m" 'org-insert-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7802 (define-key org-mode-map "\M-\C-m" 'org-insert-heading)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7803 (define-key org-mode-map "\C-c\C-l" 'org-insert-link)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7804 (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
7805 (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
7806 (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
7807 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7808 (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
7809 (define-key org-mode-map "\C-c>" 'org-goto-calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7810 (define-key org-mode-map "\C-c<" 'org-date-from-calendar)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7811 (define-key org-mode-map "\C-c[" 'org-add-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7812 (define-key org-mode-map "\C-c]" 'org-remove-file)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7813 (define-key org-mode-map "\C-c\C-r" 'org-timeline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7814 ;(define-key org-mode-map [(shift up)] 'org-timestamp-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7815 ;(define-key org-mode-map [(shift down)] 'org-timestamp-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7816 (define-key org-mode-map [(shift up)] 'org-shiftup)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7817 (define-key org-mode-map [(shift down)] 'org-shiftdown)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7818 (define-key org-mode-map [(shift left)] 'org-timestamp-down-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7819 (define-key org-mode-map [(shift right)] 'org-timestamp-up-day)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7820 (define-key org-mode-map "\C-c-" 'org-table-insert-hline)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7821 ;; 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
7822 (unless org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7823 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7824 (define-key org-mode-map [(shift tab)] 'org-shifttab)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7825 (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
7826 (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
7827 (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
7828 (define-key org-mode-map [(meta return)] 'org-meta-return)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7829 (define-key org-mode-map [(control up)] 'org-move-line-up)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7830 (define-key org-mode-map [(control down)] 'org-move-line-down)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7831 (define-key org-mode-map "\C-c?" 'org-table-current-column)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7832 (define-key org-mode-map "\C-c " 'org-table-blank-field)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7833 (define-key org-mode-map "\C-c+" 'org-table-sum)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7834 (define-key org-mode-map "\C-c|" 'org-table-toggle-vline-visibility)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7835 (define-key org-mode-map "\C-c=" 'org-table-eval-formula)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7836 (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
7837 (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
7838 (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
7839 (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
7840 (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
7841 (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
7842 ;(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
7843 ;(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
7844 (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
7845 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7846 (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
7847 (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
7848
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7849
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7850 ;; 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
7851 ;; 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
7852 ;; 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
7853
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7854 (defsubst org-table-p ()
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7855 (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
7856 (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
7857 (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
7858
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7859 (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
7860 "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
7861 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
7862 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
7863 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7864 (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
7865 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7866 (looking-at "[^|\n]* +|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7867 (let (org-table-may-need-update (pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7868 (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
7869 (delete-backward-char 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7870 (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
7871 (self-insert-command N))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7872 (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
7873 (self-insert-command N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7874
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7875 ;; FIXME:
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7876 ;; 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
7877 ;; 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
7878
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7879 (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
7880 "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
7881 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
7882 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
7883 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
7884 reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7885 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7886 (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
7887 (eq N 1)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7888 (looking-at ".*?|"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7889 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7890 (backward-delete-char N)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7891 (skip-chars-forward "^|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7892 (insert " ")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7893 (goto-char (1- pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7894 (backward-delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7895
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7896 (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
7897 "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
7898 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
7899 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
7900 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
7901 a reduced column width."
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7902 (interactive "p")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7903 (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
7904 (eq N 1))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7905 (if (looking-at ".*?|")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7906 (let ((pos (point)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7907 (replace-match (concat
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7908 (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
7909 " |"))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7910 (goto-char pos)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7911 (delete-char N)))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7912
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7913 ;; 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
7914 ;; 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
7915
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7916 (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
7917 ;; 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
7918 ;; some standard editing functions
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
7919 (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
7920 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
7921 (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
7922 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
7923 (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
7924 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
7925 (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
7926
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7927 (defun org-shiftcursor-error ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7928 "Throw an error because Shift-Cursor command was applied in wrong context."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7929 (error "This command is only active in tables and on headlines."))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7930
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7931 (defun org-shifttab ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7932 "Call `(org-cycle t)' or `org-table-previous-field'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7933 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7934 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7935 ((org-at-table-p) (org-table-previous-field))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7936 (t (org-cycle '(4)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7937
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7938 (defun org-shiftmetaleft (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7939 "Call `org-promote-subtree' or `org-table-delete-column'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7940 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7941 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7942 ((org-at-table-p) (org-table-delete-column arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7943 ((org-on-heading-p) (org-promote-subtree arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7944 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7945 (defun org-shiftmetaright (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7946 "Call `org-demote-subtree' or `org-table-insert-column'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7947 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7948 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7949 ((org-at-table-p) (org-table-insert-column arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7950 ((org-on-heading-p) (org-demote-subtree arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7951 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7952 (defun org-shiftmetaup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7953 "Call `org-move-subtree-up' or `org-table-kill-row'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7954 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7955 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7956 ((org-at-table-p) (org-table-kill-row arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7957 ((org-on-heading-p) (org-move-subtree-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7958 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7959 (defun org-shiftmetadown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7960 "Call `org-move-subtree-down' or `org-table-insert-row'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7961 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7962 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7963 ((org-at-table-p) (org-table-insert-row arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7964 ((org-on-heading-p) (org-move-subtree-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7965 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7966
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7967 (defun org-metaleft (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7968 "Call `org-do-promote' or `org-table-move-column' to left."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7969 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7970 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7971 ((org-at-table-p) (org-table-move-column 'left))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7972 ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7973 (t (backward-word (prefix-numeric-value arg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7974 (defun org-metaright (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7975 "Call `org-do-demote' or `org-table-move-column' to right."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7976 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7977 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7978 ((org-at-table-p) (org-table-move-column nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7979 ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7980 (t (forward-word (prefix-numeric-value arg)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7981 (defun org-metaup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7982 "Call `org-move-subtree-up' or `org-table-move-row' up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7983 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7984 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7985 ((org-at-table-p) (org-table-move-row 'up))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7986 ((org-on-heading-p) (org-move-subtree-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7987 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7988 (defun org-metadown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7989 "Call `org-move-subtree-down' or `org-table-move-row' down."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7990 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7991 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7992 ((org-at-table-p) (org-table-move-row nil))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7993 ((org-on-heading-p) (org-move-subtree-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7994 (t (org-shiftcursor-error))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7995
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7996 (defun org-shiftup (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7997 "Call `org-timestamp-up' or `org-priority-up'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7998 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7999 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8000 ((org-at-timestamp-p) (org-timestamp-up arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8001 (t (org-priority-up))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8002
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8003 (defun org-shiftdown (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8004 "Call `org-timestamp-down' or `org-priority-down'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8005 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8006 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8007 ((org-at-timestamp-p) (org-timestamp-down arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8008 (t (org-priority-down))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8009
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8010 (defun org-copy-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8011 "Call either `org-table-copy' or `org-copy-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8012 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8013 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8014 (org-table-copy-region arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8015 (org-copy-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8016
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8017 (defun org-cut-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8018 "Call either `org-table-copy' or `org-copy-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8019 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8020 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8021 (org-table-cut-region arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8022 (org-cut-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8023
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8024 (defun org-paste-special (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8025 "Call either `org-table-paste-rectangle' or `org-paste-subtree'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8026 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8027 (if (org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8028 (org-table-paste-rectangle arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8029 (org-paste-subtree arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8030
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8031 (defun org-ctrl-c-ctrl-c (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8032 "Call realign table, or recognize a table.el table.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8033 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
8034 activate that table. Otherwise, if the cursor is at a normal table
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8035 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
8036 the automatic table editor has been turned off."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8037 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8038 (let ((org-enable-table-editor t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8039 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8040 ((org-at-table.el-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8041 (require 'table)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8042 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8043 (re-search-forward "|" (save-excursion (end-of-line 2) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8044 (table-recognize-table))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8045 ((org-at-table-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8046 (org-table-align))
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8047 ((save-excursion (beginning-of-line 1) (looking-at "#\\+[A-Z]+"))
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8048 (let (org-inhibit-startup) (org-mode)))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8049 ((org-region-active-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8050 (org-table-convert-region (region-beginning) (region-end) arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8051 ((and (region-beginning) (region-end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8052 (if (y-or-n-p "Convert inactive region to table? ")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8053 (org-table-convert-region (region-beginning) (region-end) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8054 (error "Abort")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8055 (t (error "No table at point, and no region to make one.")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8056
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8057 (defun org-return (&optional arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8058 "Call `org-table-next-row' or `newline'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8059 (interactive "P")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8060 (cond
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8061 ((org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8062 (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
8063 (org-table-next-row))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8064 (t (newline))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8065
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8066 (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
8067 "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
8068 (interactive "P")
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8069 (cond
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8070 ((org-at-table-p)
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8071 (org-table-wrap-region arg))
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8072 (t (org-insert-heading arg))))
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8073
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8074 ;;; Menu entries
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8075
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8076 ;; First, remove the outline menus.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8077 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8078 (add-hook 'org-mode-hook
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8079 (lambda ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8080 (delete-menu-item '("Headings"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8081 (delete-menu-item '("Show"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8082 (delete-menu-item '("Hide"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8083 (set-menubar-dirty-flag)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8084 (setq org-mode-map (delq (assoc 'menu-bar (cdr org-mode-map))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8085 org-mode-map)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8086
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8087 ;; Define the Org-mode menus
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8088 (easy-menu-define org-org-menu org-mode-map "Org menu"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8089 '("Org"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8090 ["Cycle Visibility" org-cycle (or (bobp) (outline-on-heading-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8091 ["Sparse Tree" org-occur t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8092 ["Show All" show-all t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8093 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8094 ["New Heading" org-insert-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8095 ("Navigate Headings"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8096 ["Up" outline-up-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8097 ["Next" outline-next-visible-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8098 ["Previous" outline-previous-visible-heading t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8099 ["Next Same Level" outline-forward-same-level t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8100 ["Previous Same Level" outline-backward-same-level t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8101 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8102 ["Jump" org-goto t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8103 ("Edit Structure"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8104 ["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
8105 ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8106 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8107 ["Copy Subtree" org-copy-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8108 ["Cut Subtree" org-cut-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8109 ["Paste Subtree" org-paste-special (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8110 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8111 ["Promote Heading" org-metaleft (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8112 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8113 ["Demote Heading" org-metaright (not (org-at-table-p))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8114 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8115 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8116 ("TODO Lists"
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8117 ["TODO/DONE/-" org-todo t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8118 ["Show TODO Tree" org-show-todo-tree t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8119 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8120 ["Set Priority" org-priority t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8121 ["Priority Up" org-shiftup t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8122 ["Priority Down" org-shiftdown t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8123 ("Dates and Scheduling"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8124 ["Timestamp" org-time-stamp t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8125 ("Change Date"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8126 ["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
8127 ["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
8128 ["1 ... Later" org-shiftup t]
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8129 ["1 ... Earlier" org-shiftdown t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8130 ["Compute Time Range" org-evaluate-time-range t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8131 ["Schedule Item" org-schedule t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8132 ["Deadline" org-deadline t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8133 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8134 ["Goto Calendar" org-goto-calendar t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8135 ["Date from Calendar" org-date-from-calendar t])
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 ("Timeline/Agenda"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8138 ["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
8139 ["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
8140 ["Timeline Current File" org-timeline t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8141 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8142 ["Agenda" org-agenda t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8143 ("File List for Agenda")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8144 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8145 ("Hyperlinks"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8146 ["Store Link (Global)" org-store-link t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8147 ["Insert Link" org-insert-link t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8148 ["Follow Link" org-open-at-point t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8149 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8150 ("Table"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8151 ["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
8152 ["Next Field" org-cycle (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8153 ["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
8154 ["Next Row" org-return (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8155 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8156 ["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
8157 ["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
8158 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8159 ("Column"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8160 ["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
8161 ["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
8162 ["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
8163 ["Insert Column" org-shiftmetaright (org-at-table-p)])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8164 ("Row"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8165 ["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
8166 ["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
8167 ["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
8168 ["Insert Row" org-shiftmetadown (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8169 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8170 ["Insert Hline" org-table-insert-hline (org-at-table-p)])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8171 ("Rectangle"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8172 ["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
8173 ["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
8174 ["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
8175 ["Fill Rectangle" org-table-wrap-region (org-at-table-p)])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8176 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8177 ["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
8178 ["Sum Column/Rectangle" org-table-sum
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8179 (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
8180 ["Eval Formula" org-table-eval-formula (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8181 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8182 ["Invisible Vlines" org-table-toggle-vline-visibility
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8183 :style toggle :selected (org-in-invisibility-spec-p '(org-table))]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8184 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8185 ["Create" org-table-create (and (not (org-at-table-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8186 org-enable-table-editor)]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8187 ["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
8188 ["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
8189 ["Export to File" org-table-export (org-at-table-p)]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8190 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8191 ["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
8192 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8193 ("Export"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8194 ["ASCII" org-export-as-ascii t]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8195 ["Extract Visible Text" org-export-copy-visible t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8196 ["HTML" org-export-as-html t]
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8197 ["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
8198 ; ["OPML" org-export-as-opml nil]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8199 "--"
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8200 ["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
8201 ["Toggle Fixed Width" org-toggle-fixed-width-section t])
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8202 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8203 ("Documentation"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8204 ["Show Version" org-version t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8205 ["Info Documentation" org-info t])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8206 ("Customize"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8207 ["Browse Org Group" org-customize t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8208 "--"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8209 ["Build Full Customize Menu" org-create-customize-menu
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8210 (fboundp 'customize-menu-create)])
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8211 ))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8212
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8213 (defun org-info (&optional node)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8214 "Read documentation for Org-mode in the info system.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8215 With optional NODE, go directly to that node."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8216 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8217 (require 'info)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8218 (Info-goto-node (format "(org)%s" (or node ""))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8219
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8220 (defun org-install-agenda-files-menu ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8221 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8222 '("Org") "File List for Agenda"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8223 (append
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8224 (list
61560
a54fc673c31c (org-agenda-date-prompt): Renamed from
Carsten Dominik <dominik@science.uva.nl>
parents: 61312
diff changeset
8225 ["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
8226 ["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
8227 ["Remove Current File from List" org-remove-file t]
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8228 "--")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8229 (mapcar 'org-file-menu-entry org-agenda-files))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8230
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8231 ;;; Documentation
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8232
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8233 (defun org-customize ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8234 "Call the customize function with org as argument."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8235 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8236 (customize-browse 'org))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8237
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8238 (defun org-create-customize-menu ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8239 "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
8240 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8241 (if (fboundp 'customize-menu-create)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8242 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8243 (easy-menu-change
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8244 '("Org") "Customize"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8245 `(["Browse Org group" org-customize 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 ,(customize-menu-create 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8248 ["Set" Custom-set t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8249 ["Save" Custom-save t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8250 ["Reset to Current" Custom-reset-current t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8251 ["Reset to Saved" Custom-reset-saved t]
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8252 ["Reset to Standard Settings" Custom-reset-standard t]))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8253 (message "\"Org\"-menu now contains full customization menu"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8254 (error "Cannot expand menu (outdated version of cus-edit.el)")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8255
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8256 ;;; Miscellaneous stuff
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 (defun org-move-line-down (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8259 "Move the current line up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8260 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8261 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8262 beg end pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8263 (beginning-of-line 1) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8264 (beginning-of-line 2) (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8265 (beginning-of-line (+ 1 arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8266 (setq pos (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8267 (insert (delete-and-extract-region beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8268 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8269 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8270
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8271 (defun org-move-line-up (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8272 "Move the current line up."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8273 (interactive "p")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8274 (let ((col (current-column))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8275 beg end pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8276 (beginning-of-line 1) (setq beg (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8277 (beginning-of-line 2) (setq end (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8278 (beginning-of-line (+ -2 arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8279 (setq pos (move-marker (make-marker) (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8280 (insert (delete-and-extract-region beg end))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8281 (goto-char pos)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8282 (move-to-column col)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8283
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8284 ;; Functions needed for Emacs/XEmacs region compatibility
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8285
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8286 (defun org-region-active-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8287 "Is transient-mark-mode on and the region active?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8288 Works on both Emacs and XEmacs."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8289 (if org-ignore-region
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8290 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8291 (if org-xemacs-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8292 (and zmacs-regions (region-active-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8293 (and transient-mark-mode mark-active))))
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 (defun org-add-to-invisibility-spec (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8296 "Add elements to `buffer-invisibility-spec'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8297 See documentation for `buffer-invisibility-spec' for the kind of elements
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8298 that can be added."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8299 (cond
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8300 ((fboundp 'add-to-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8301 (add-to-invisibility-spec arg))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8302 ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8303 (setq buffer-invisibility-spec (list arg)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8304 (t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8305 (setq buffer-invisibility-spec
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8306 (cons arg buffer-invisibility-spec)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8307
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8308 (defun org-remove-from-invisibility-spec (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8309 "Remove elements from `buffer-invisibility-spec'."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8310 (if (fboundp 'remove-from-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8311 (remove-from-invisibility-spec arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8312 (if (consp buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8313 (setq buffer-invisibility-spec
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8314 (delete arg buffer-invisibility-spec)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8315
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8316 (defun org-in-invisibility-spec-p (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8317 "Is ARG a member of `buffer-invisibility-spec'?."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8318 (if (consp buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8319 (member arg buffer-invisibility-spec)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8320 nil))
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 (defun org-image-file-name-regexp ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8323 "Return regexp matching the file names of images."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8324 (if (fboundp 'image-file-name-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8325 (image-file-name-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8326 (let ((image-file-name-extensions
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8327 '("png" "jpeg" "jpg" "gif" "tiff" "tif"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8328 "xbm" "xpm" "pbm" "pgm" "ppm")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8329 (concat "\\."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8330 (regexp-opt (nconc (mapcar 'upcase
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8331 image-file-name-extensions)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8332 image-file-name-extensions)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8333 t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8334 "\\'"))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8335
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8336 ;; Functions needed for compatibility with old outline.el
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8337
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8338 ;; The following functions capture almost the entire compatibility code
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8339 ;; between the different versions of outline-mode. The only other place
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8340 ;; where this is important are the font-lock-keywords. Search for
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8341 ;; `org-noutline-p' to find it.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8342
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8343 ;; 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
8344 ;; new outline.el. I guess this should be patched into Emacs?
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8345 (defun org-beginning-of-line ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8346 "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
8347 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
8348 (interactive)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8349 (beginning-of-line 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8350 (if (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8351 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8352 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8353 (if (org-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8354 (while (and (not (bobp)) (org-invisible-p))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8355 (backward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8356 (beginning-of-line 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8357 (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8358 (when org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8359 (define-key org-mode-map "\C-a" 'org-beginning-of-line))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8360
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8361 (defun org-invisible-p ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8362 "Check if point is at a character currently not visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8363 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8364 ;; Early versions of noutline don't have `outline-invisible-p'.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8365 (if (fboundp 'outline-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8366 (outline-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8367 (get-char-property (point) 'invisible))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8368 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8369 (skip-chars-backward "^\r\n")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8370 (if (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8371 nil
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8372 (equal (char-before) ?\r)))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8373
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8374 (defun org-back-to-heading (&optional invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8375 "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
8376 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8377 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8378 (outline-back-to-heading invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8379 (if (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8380 t
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8381 (if (re-search-backward (concat (if invisible-ok "[\r\n]" "^")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8382 outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8383 nil t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8384 (if invisible-ok
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8385 (progn (forward-char 1)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8386 (looking-at outline-regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8387 (error "Before first heading")))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8388
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8389 (defun org-on-heading-p (&optional invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8390 "Return t if point is on a (visible) heading line.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8391 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
8392 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8393 (outline-on-heading-p 'invisible-ok)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8394 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8395 (skip-chars-backward "^\n\r")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8396 (and (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8397 (or invisible-ok
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8398 (bobp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8399 (equal (char-before) ?\n))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8400
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8401 (defun org-up-heading-all (arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8402 "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
8403 This function considers both visible and invisible heading lines.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8404 With argument, move up ARG levels."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8405 (if org-noutline-p
61582
e0ff525f6d80 (org-up-heading-all): Fixed bug with
Carsten Dominik <dominik@science.uva.nl>
parents: 61561
diff changeset
8406 (outline-up-heading arg t)
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8407 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8408 (looking-at outline-regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8409 (if (<= (- (match-end 0) (match-beginning 0)) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8410 (error "Cannot move up %d levels" arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8411 (re-search-backward
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8412 (concat "[\n\r]" (regexp-quote
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8413 (make-string (- (match-end 0) (match-beginning 0) arg)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8414 ?*))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8415 "[^*]"))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8416 (forward-char 1))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8417
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8418 (defun org-show-hidden-entry ()
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8419 "Show an entry where even the heading is hidden."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8420 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8421 (if (not org-noutline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8422 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8423 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8424 (org-flag-heading nil)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8425 (show-entry)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8426
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8427 (defun org-check-occur-regexp (regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8428 "If REGEXP starts with \"^\", modify it to check for \\r as well.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8429 Of course, only for the old outline mode."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8430 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8431 regexp
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8432 (if (string-match "^\\^" regexp)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8433 (concat "[\n\r]" (substring regexp 1))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8434 regexp)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8435
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8436 (defun org-flag-heading (flag &optional entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8437 "Flag the current heading. FLAG non-nil means make invisible.
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8438 When ENTRY is non-nil, show the entire entry."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8439 (save-excursion
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8440 (org-back-to-heading t)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8441 (if (not org-noutline-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8442 ;; Make the current headline visible
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8443 (outline-flag-region (max 1 (1- (point))) (point) (if flag ?\r ?\n)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8444 ;; Check if we should show the entire entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8445 (if entry
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8446 (progn
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8447 (show-entry)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8448 (save-excursion ;; FIXME: Is this the fix for points in the -|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8449 ;; middle of text? |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8450 (and (outline-next-heading) ;; |
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8451 (org-flag-heading nil)))) ; show the next heading _|
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8452 (outline-flag-region (max 1 (1- (point)))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8453 (save-excursion (outline-end-of-heading) (point))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8454 (if org-noutline-p
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8455 flag
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8456 (if flag ?\r ?\n))))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8457
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8458 (defun org-make-options-regexp (kwds)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8459 "Make a regular expression for keyword lines."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8460 (concat
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8461 (if org-noutline-p "^" "[\n\r]")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8462 "#?[ \t]*\\+\\("
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8463 (mapconcat 'regexp-quote kwds "\\|")
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8464 "\\):[ \t]*"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8465 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)")))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8466
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8467 ;; Advise the bookmark-jump function to make jump position visible
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8468 ;; Wrapped into eval-after-load to avoid loading advice unnecessarily
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8469 (eval-after-load "bookmark"
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8470 '(defadvice bookmark-jump (after org-make-visible activate)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8471 "Make the position visible."
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8472 (and (eq major-mode 'org-mode)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8473 (org-invisible-p)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8474 (org-show-hierarchy-above))))
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8475
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8476 ;;; Finish up
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8477
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8478 (provide 'org)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8479
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8480 (run-hooks 'org-load-hook)
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8481
59539
998101ef8562 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 58841
diff changeset
8482 ;; 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
8483
58792
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8484 ;;; org.el ends here
265139cbc47c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8485