diff options
| author | Carsten Dominik | 2006-01-13 11:29:17 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2006-01-13 11:29:17 +0000 |
| commit | 70a539ca222d7dc1a02d7c68faf6657d2c42f5d4 (patch) | |
| tree | 1900e6e9affca65f5774f80f57387137cb0286c5 | |
| parent | fc8a237d21aab7ab29229aa2910f9c46871cb865 (diff) | |
| download | emacs-70a539ca222d7dc1a02d7c68faf6657d2c42f5d4.tar.gz emacs-70a539ca222d7dc1a02d7c68faf6657d2c42f5d4.zip | |
(org-open-file): Use mailcap for selecting an
application.
(org-file-apps-defaults-gnu): Use mailcap as the default for
selecting an application on a UNIX system.
(org-agenda-show-tags): New command.
(org-table-insert-hline): Keep cursor in current table
line.
(org-table-convert): Offset effect of modifying
`org-table-insert-hline'.
(org-format-agenda-item): New optional argument TAG.
(org-compile-prefix-format): Handle %T format for the tag.
(org-expand-wide-chars): New function.
(org-table-insert-row, org-table-insert-hline): Use
`org-expand-wide-chars'.
(org-open-file): Fixed bug in program launch.
(org-get-time-of-day): Fixed bug with times before 1am.
(org-agenda-menu): Addes tags commands.
| -rw-r--r-- | lisp/textmodes/org.el | 173 |
1 files changed, 113 insertions, 60 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index dfb169769d3..ef8dba71f04 100644 --- a/lisp/textmodes/org.el +++ b/lisp/textmodes/org.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Carsten Dominik <dominik at science dot uva dot nl> | 5 | ;; Author: Carsten Dominik <dominik at science dot uva dot nl> |
| 6 | ;; Keywords: outlines, hypermedia, calendar, wp | 6 | ;; Keywords: outlines, hypermedia, calendar, wp |
| 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ | 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ |
| 8 | ;; Version: 4.02 | 8 | ;; Version: 4.03 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -81,6 +81,12 @@ | |||
| 81 | ;; | 81 | ;; |
| 82 | ;; Changes since version 4.00: | 82 | ;; Changes since version 4.00: |
| 83 | ;; --------------------------- | 83 | ;; --------------------------- |
| 84 | ;; Version 4.03 | ||
| 85 | ;; - Table alignment fixed for use with wide characters. | ||
| 86 | ;; - `C-c -' leaves cursor in current table line. | ||
| 87 | ;; - The current TAG can be incorporated into the agenda prefix. | ||
| 88 | ;; See option `org-agenda-prefix-format' for details. | ||
| 89 | ;; | ||
| 84 | ;; Version 4.02 | 90 | ;; Version 4.02 |
| 85 | ;; - Minor bug fixes and improvements around tag searches. | 91 | ;; - Minor bug fixes and improvements around tag searches. |
| 86 | ;; - XEmacs compatibility fixes. | 92 | ;; - XEmacs compatibility fixes. |
| @@ -105,7 +111,7 @@ | |||
| 105 | 111 | ||
| 106 | ;;; Customization variables | 112 | ;;; Customization variables |
| 107 | 113 | ||
| 108 | (defvar org-version "4.01" | 114 | (defvar org-version "4.03" |
| 109 | "The version number of the file org.el.") | 115 | "The version number of the file org.el.") |
| 110 | (defun org-version () | 116 | (defun org-version () |
| 111 | (interactive) | 117 | (interactive) |
| @@ -565,6 +571,7 @@ This format works similar to a printf format, with the following meaning: | |||
| 565 | 571 | ||
| 566 | %c the category of the item, \"Diary\" for entries from the diary, or | 572 | %c the category of the item, \"Diary\" for entries from the diary, or |
| 567 | as given by the CATEGORY keyword or derived from the file name. | 573 | as given by the CATEGORY keyword or derived from the file name. |
| 574 | %T the first tag of the item. | ||
| 568 | %t the time-of-day specification if one applies to the entry, in the | 575 | %t the time-of-day specification if one applies to the entry, in the |
| 569 | format HH:MM | 576 | format HH:MM |
| 570 | %s Scheduling/Deadline information, a short string | 577 | %s Scheduling/Deadline information, a short string |
| @@ -1012,29 +1019,7 @@ The default is true, to keep new users from shooting into their own foot." | |||
| 1012 | :type 'boolean) | 1019 | :type 'boolean) |
| 1013 | 1020 | ||
| 1014 | (defconst org-file-apps-defaults-gnu | 1021 | (defconst org-file-apps-defaults-gnu |
| 1015 | '((t . emacs) | 1022 | '((t . mailcap)) |
| 1016 | ("jpg" . "xv %s") | ||
| 1017 | ("gif" . "xv %s") | ||
| 1018 | ("ppm" . "xv %s") | ||
| 1019 | ("pgm" . "xv %s") | ||
| 1020 | ("pbm" . "xv %s") | ||
| 1021 | ("tif" . "xv %s") | ||
| 1022 | ("png" . "xv %s") | ||
| 1023 | ("ps" . "gv %s") | ||
| 1024 | ("ps.gz" . "gv %s") | ||
| 1025 | ("eps" . "gv %s") | ||
| 1026 | ("eps.gz" . "gv %s") | ||
| 1027 | ("dvi" . "xdvi %s") | ||
| 1028 | ("mpeg" . "plaympeg %s") | ||
| 1029 | ("mp3" . "plaympeg %s") | ||
| 1030 | ("fig" . "xfig %s") | ||
| 1031 | ("pdf" . "acroread %s") | ||
| 1032 | ("doc" . "soffice %s") | ||
| 1033 | ("ppt" . "soffice %s") | ||
| 1034 | ("pps" . "soffice %s") | ||
| 1035 | ("html" . "netscape -remote openURL(%s,new-window)") | ||
| 1036 | ("htm" . "netscape -remote openURL(%s,new-window)") | ||
| 1037 | ("xs" . "soffice %s")) | ||
| 1038 | "Default file applications on a UNIX/LINUX system. | 1023 | "Default file applications on a UNIX/LINUX system. |
| 1039 | See `org-file-apps'.") | 1024 | See `org-file-apps'.") |
| 1040 | 1025 | ||
| @@ -4186,6 +4171,7 @@ The following commands are available: | |||
| 4186 | (define-key org-agenda-mode-map "q" 'org-agenda-quit) | 4171 | (define-key org-agenda-mode-map "q" 'org-agenda-quit) |
| 4187 | (define-key org-agenda-mode-map "x" 'org-agenda-exit) | 4172 | (define-key org-agenda-mode-map "x" 'org-agenda-exit) |
| 4188 | (define-key org-agenda-mode-map "P" 'org-agenda-show-priority) | 4173 | (define-key org-agenda-mode-map "P" 'org-agenda-show-priority) |
| 4174 | (define-key org-agenda-mode-map "T" 'org-agenda-show-tags) | ||
| 4189 | (define-key org-agenda-mode-map "n" 'next-line) | 4175 | (define-key org-agenda-mode-map "n" 'next-line) |
| 4190 | (define-key org-agenda-mode-map "p" 'previous-line) | 4176 | (define-key org-agenda-mode-map "p" 'previous-line) |
| 4191 | (define-key org-agenda-mode-map "\C-n" 'org-agenda-next-date-line) | 4177 | (define-key org-agenda-mode-map "\C-n" 'org-agenda-next-date-line) |
| @@ -4232,7 +4218,9 @@ The following commands are available: | |||
| 4232 | :style toggle :selected org-agenda-follow-mode :active t] | 4218 | :style toggle :selected org-agenda-follow-mode :active t] |
| 4233 | "--" | 4219 | "--" |
| 4234 | ["Cycle TODO" org-agenda-todo t] | 4220 | ["Cycle TODO" org-agenda-todo t] |
| 4235 | ["Set Tags" org-agenda-set-tags t] | 4221 | ("Tags" |
| 4222 | ["Show all Tags" org-agenda-show-tags t] | ||
| 4223 | ["Set Tags" org-agenda-set-tags t]) | ||
| 4236 | ("Reschedule" | 4224 | ("Reschedule" |
| 4237 | ["Reschedule +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)] | 4225 | ["Reschedule +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)] |
| 4238 | ["Reschedule -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)] | 4226 | ["Reschedule -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)] |
| @@ -4946,7 +4934,7 @@ With prefix ARG, go back that many times `org-agenda-ndays'." | |||
| 4946 | (setq entries | 4934 | (setq entries |
| 4947 | (mapcar | 4935 | (mapcar |
| 4948 | (lambda (x) | 4936 | (lambda (x) |
| 4949 | (setq x (org-format-agenda-item "" x "Diary" 'time)) | 4937 | (setq x (org-format-agenda-item "" x "Diary" nil 'time)) |
| 4950 | ;; Extend the text properties to the beginning of the line | 4938 | ;; Extend the text properties to the beginning of the line |
| 4951 | (add-text-properties | 4939 | (add-text-properties |
| 4952 | 0 (length x) | 4940 | 0 (length x) |
| @@ -5297,14 +5285,15 @@ the documentation of `org-diary'." | |||
| 5297 | "\\)\\>") | 5285 | "\\)\\>") |
| 5298 | org-not-done-regexp) | 5286 | org-not-done-regexp) |
| 5299 | "[^\n\r]*\\)")) | 5287 | "[^\n\r]*\\)")) |
| 5300 | marker priority category | 5288 | marker priority category tags |
| 5301 | ee txt) | 5289 | ee txt) |
| 5302 | (goto-char (point-min)) | 5290 | (goto-char (point-min)) |
| 5303 | (while (re-search-forward regexp nil t) | 5291 | (while (re-search-forward regexp nil t) |
| 5304 | (goto-char (match-beginning 1)) | 5292 | (goto-char (match-beginning 1)) |
| 5305 | (setq marker (org-agenda-new-marker (1+ (match-beginning 0))) | 5293 | (setq marker (org-agenda-new-marker (1+ (match-beginning 0))) |
| 5306 | category (org-get-category) | 5294 | category (org-get-category) |
| 5307 | txt (org-format-agenda-item "" (match-string 1) category) | 5295 | tags (org-get-tags-at (point)) |
| 5296 | txt (org-format-agenda-item "" (match-string 1) category tags) | ||
| 5308 | priority | 5297 | priority |
| 5309 | (+ (org-get-priority txt) | 5298 | (+ (org-get-priority txt) |
| 5310 | (if org-todo-kwd-priority-p | 5299 | (if org-todo-kwd-priority-p |
| @@ -5340,7 +5329,7 @@ the documentation of `org-diary'." | |||
| 5340 | (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) | 5329 | (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) |
| 5341 | 0 11))) | 5330 | 0 11))) |
| 5342 | marker hdmarker deadlinep scheduledp donep tmp priority category | 5331 | marker hdmarker deadlinep scheduledp donep tmp priority category |
| 5343 | ee txt timestr) | 5332 | ee txt timestr tags) |
| 5344 | (goto-char (point-min)) | 5333 | (goto-char (point-min)) |
| 5345 | (while (re-search-forward regexp nil t) | 5334 | (while (re-search-forward regexp nil t) |
| 5346 | (if (not (save-match-data (org-at-date-range-p))) | 5335 | (if (not (save-match-data (org-at-date-range-p))) |
| @@ -5362,13 +5351,14 @@ the documentation of `org-diary'." | |||
| 5362 | (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t) | 5351 | (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t) |
| 5363 | (progn | 5352 | (progn |
| 5364 | (goto-char (match-end 1)) | 5353 | (goto-char (match-end 1)) |
| 5365 | (setq hdmarker (org-agenda-new-marker)) | 5354 | (setq hdmarker (org-agenda-new-marker) |
| 5355 | tags (org-get-tags-at)) | ||
| 5366 | (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") | 5356 | (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") |
| 5367 | (setq txt (org-format-agenda-item | 5357 | (setq txt (org-format-agenda-item |
| 5368 | (format "%s%s" | 5358 | (format "%s%s" |
| 5369 | (if deadlinep "Deadline: " "") | 5359 | (if deadlinep "Deadline: " "") |
| 5370 | (if scheduledp "Scheduled: " "")) | 5360 | (if scheduledp "Scheduled: " "")) |
| 5371 | (match-string 1) category timestr))) | 5361 | (match-string 1) category tags timestr))) |
| 5372 | (setq txt org-agenda-no-heading-message)) | 5362 | (setq txt org-agenda-no-heading-message)) |
| 5373 | (setq priority (org-get-priority txt)) | 5363 | (setq priority (org-get-priority txt)) |
| 5374 | (add-text-properties | 5364 | (add-text-properties |
| @@ -5417,7 +5407,7 @@ the documentation of `org-diary'." | |||
| 5417 | (apply 'encode-time ; DATE bound by calendar | 5407 | (apply 'encode-time ; DATE bound by calendar |
| 5418 | (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) | 5408 | (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) |
| 5419 | 1 11)))) | 5409 | 1 11)))) |
| 5420 | marker hdmarker priority category | 5410 | marker hdmarker priority category tags |
| 5421 | ee txt timestr) | 5411 | ee txt timestr) |
| 5422 | (goto-char (point-min)) | 5412 | (goto-char (point-min)) |
| 5423 | (while (re-search-forward regexp nil t) | 5413 | (while (re-search-forward regexp nil t) |
| @@ -5435,11 +5425,12 @@ the documentation of `org-diary'." | |||
| 5435 | (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t) | 5425 | (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t) |
| 5436 | (progn | 5426 | (progn |
| 5437 | (goto-char (match-end 1)) | 5427 | (goto-char (match-end 1)) |
| 5438 | (setq hdmarker (org-agenda-new-marker)) | 5428 | (setq hdmarker (org-agenda-new-marker) |
| 5429 | tags (org-get-tags-at)) | ||
| 5439 | (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") | 5430 | (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") |
| 5440 | (setq txt (org-format-agenda-item | 5431 | (setq txt (org-format-agenda-item |
| 5441 | "Closed: " | 5432 | "Closed: " |
| 5442 | (match-string 1) category timestr))) | 5433 | (match-string 1) category tags timestr))) |
| 5443 | (setq txt org-agenda-no-heading-message)) | 5434 | (setq txt org-agenda-no-heading-message)) |
| 5444 | (setq priority 100000) | 5435 | (setq priority 100000) |
| 5445 | (add-text-properties | 5436 | (add-text-properties |
| @@ -5466,7 +5457,7 @@ the documentation of `org-diary'." | |||
| 5466 | (regexp org-deadline-time-regexp) | 5457 | (regexp org-deadline-time-regexp) |
| 5467 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar | 5458 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar |
| 5468 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar | 5459 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar |
| 5469 | d2 diff pos pos1 category | 5460 | d2 diff pos pos1 category tags |
| 5470 | ee txt head) | 5461 | ee txt head) |
| 5471 | (goto-char (point-min)) | 5462 | (goto-char (point-min)) |
| 5472 | (while (re-search-forward regexp nil t) | 5463 | (while (re-search-forward regexp nil t) |
| @@ -5484,6 +5475,7 @@ the documentation of `org-diary'." | |||
| 5484 | (progn | 5475 | (progn |
| 5485 | (goto-char (match-end 0)) | 5476 | (goto-char (match-end 0)) |
| 5486 | (setq pos1 (match-end 1)) | 5477 | (setq pos1 (match-end 1)) |
| 5478 | (setq tags (org-get-tags-at pos1)) | ||
| 5487 | (setq head (buffer-substring-no-properties | 5479 | (setq head (buffer-substring-no-properties |
| 5488 | (point) | 5480 | (point) |
| 5489 | (progn (skip-chars-forward "^\r\n") | 5481 | (progn (skip-chars-forward "^\r\n") |
| @@ -5491,7 +5483,7 @@ the documentation of `org-diary'." | |||
| 5491 | (if (string-match org-looking-at-done-regexp head) | 5483 | (if (string-match org-looking-at-done-regexp head) |
| 5492 | (setq txt nil) | 5484 | (setq txt nil) |
| 5493 | (setq txt (org-format-agenda-item | 5485 | (setq txt (org-format-agenda-item |
| 5494 | (format "In %3d d.: " diff) head category)))) | 5486 | (format "In %3d d.: " diff) head category tags)))) |
| 5495 | (setq txt org-agenda-no-heading-message)) | 5487 | (setq txt org-agenda-no-heading-message)) |
| 5496 | (when txt | 5488 | (when txt |
| 5497 | (add-text-properties | 5489 | (add-text-properties |
| @@ -5527,7 +5519,7 @@ the documentation of `org-diary'." | |||
| 5527 | (regexp org-scheduled-time-regexp) | 5519 | (regexp org-scheduled-time-regexp) |
| 5528 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar | 5520 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar |
| 5529 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar | 5521 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar |
| 5530 | d2 diff pos pos1 category | 5522 | d2 diff pos pos1 category tags |
| 5531 | ee txt head) | 5523 | ee txt head) |
| 5532 | (goto-char (point-min)) | 5524 | (goto-char (point-min)) |
| 5533 | (while (re-search-forward regexp nil t) | 5525 | (while (re-search-forward regexp nil t) |
| @@ -5544,6 +5536,7 @@ the documentation of `org-diary'." | |||
| 5544 | (progn | 5536 | (progn |
| 5545 | (goto-char (match-end 0)) | 5537 | (goto-char (match-end 0)) |
| 5546 | (setq pos1 (match-end 1)) | 5538 | (setq pos1 (match-end 1)) |
| 5539 | (setq tags (org-get-tags-at)) | ||
| 5547 | (setq head (buffer-substring-no-properties | 5540 | (setq head (buffer-substring-no-properties |
| 5548 | (point) | 5541 | (point) |
| 5549 | (progn (skip-chars-forward "^\r\n") (point)))) | 5542 | (progn (skip-chars-forward "^\r\n") (point)))) |
| @@ -5551,7 +5544,7 @@ the documentation of `org-diary'." | |||
| 5551 | (setq txt nil) | 5544 | (setq txt nil) |
| 5552 | (setq txt (org-format-agenda-item | 5545 | (setq txt (org-format-agenda-item |
| 5553 | (format "Sched.%2dx: " (- 1 diff)) head | 5546 | (format "Sched.%2dx: " (- 1 diff)) head |
| 5554 | category)))) | 5547 | category tags)))) |
| 5555 | (setq txt org-agenda-no-heading-message)) | 5548 | (setq txt org-agenda-no-heading-message)) |
| 5556 | (when txt | 5549 | (when txt |
| 5557 | (add-text-properties | 5550 | (add-text-properties |
| @@ -5574,7 +5567,7 @@ the documentation of `org-diary'." | |||
| 5574 | (abbreviate-file-name (buffer-file-name))))) | 5567 | (abbreviate-file-name (buffer-file-name))))) |
| 5575 | (regexp org-tr-regexp) | 5568 | (regexp org-tr-regexp) |
| 5576 | (d0 (calendar-absolute-from-gregorian date)) | 5569 | (d0 (calendar-absolute-from-gregorian date)) |
| 5577 | marker hdmarker ee txt d1 d2 s1 s2 timestr category) | 5570 | marker hdmarker ee txt d1 d2 s1 s2 timestr category tags) |
| 5578 | (goto-char (point-min)) | 5571 | (goto-char (point-min)) |
| 5579 | (while (re-search-forward regexp nil t) | 5572 | (while (re-search-forward regexp nil t) |
| 5580 | (setq timestr (match-string 0) | 5573 | (setq timestr (match-string 0) |
| @@ -5592,11 +5585,12 @@ the documentation of `org-diary'." | |||
| 5592 | (progn | 5585 | (progn |
| 5593 | (setq hdmarker (org-agenda-new-marker (match-end 1))) | 5586 | (setq hdmarker (org-agenda-new-marker (match-end 1))) |
| 5594 | (goto-char (match-end 1)) | 5587 | (goto-char (match-end 1)) |
| 5588 | (setq tags (org-get-tags-at)) | ||
| 5595 | (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") | 5589 | (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") |
| 5596 | (setq txt (org-format-agenda-item | 5590 | (setq txt (org-format-agenda-item |
| 5597 | (format (if (= d1 d2) "" "(%d/%d): ") | 5591 | (format (if (= d1 d2) "" "(%d/%d): ") |
| 5598 | (1+ (- d0 d1)) (1+ (- d2 d1))) | 5592 | (1+ (- d0 d1)) (1+ (- d2 d1))) |
| 5599 | (match-string 1) category | 5593 | (match-string 1) category tags |
| 5600 | (if (= d0 d1) timestr)))) | 5594 | (if (= d0 d1) timestr)))) |
| 5601 | (setq txt org-agenda-no-heading-message)) | 5595 | (setq txt org-agenda-no-heading-message)) |
| 5602 | (add-text-properties | 5596 | (add-text-properties |
| @@ -5643,7 +5637,7 @@ After a match, the following groups carry important information: | |||
| 5643 | "A flag, set by `org-compile-prefix-format'. | 5637 | "A flag, set by `org-compile-prefix-format'. |
| 5644 | The flag is set if the currently compiled format contains a `%t'.") | 5638 | The flag is set if the currently compiled format contains a `%t'.") |
| 5645 | 5639 | ||
| 5646 | (defun org-format-agenda-item (extra txt &optional category dotime noprefix) | 5640 | (defun org-format-agenda-item (extra txt &optional category tags dotime noprefix) |
| 5647 | "Format TXT to be inserted into the agenda buffer. | 5641 | "Format TXT to be inserted into the agenda buffer. |
| 5648 | In particular, it adds the prefix and corresponding text properties. EXTRA | 5642 | In particular, it adds the prefix and corresponding text properties. EXTRA |
| 5649 | must be a string and replaces the `%s' specifier in the prefix format. | 5643 | must be a string and replaces the `%s' specifier in the prefix format. |
| @@ -5654,7 +5648,7 @@ time-of-day should be extracted from TXT for sorting of this entry, and for | |||
| 5654 | the `%t' specifier in the format. When DOTIME is a string, this string is | 5648 | the `%t' specifier in the format. When DOTIME is a string, this string is |
| 5655 | searched for a time before TXT is. NOPREFIX is a flag and indicates that | 5649 | searched for a time before TXT is. NOPREFIX is a flag and indicates that |
| 5656 | only the correctly processes TXT should be returned - this is used by | 5650 | only the correctly processes TXT should be returned - this is used by |
| 5657 | `org-agenda-change-all-lines'." | 5651 | `org-agenda-change-all-lines'. TAG can be the tag of the headline." |
| 5658 | (save-match-data | 5652 | (save-match-data |
| 5659 | ;; Diary entries sometimes have extra whitespace at the beginning | 5653 | ;; Diary entries sometimes have extra whitespace at the beginning |
| 5660 | (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt))) | 5654 | (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt))) |
| @@ -5664,6 +5658,7 @@ only the correctly processes TXT should be returned - this is used by | |||
| 5664 | (file-name-sans-extension | 5658 | (file-name-sans-extension |
| 5665 | (file-name-nondirectory (buffer-file-name))) | 5659 | (file-name-nondirectory (buffer-file-name))) |
| 5666 | ""))) | 5660 | ""))) |
| 5661 | (tag (or (nth (1- (length tags)) tags) "")) | ||
| 5667 | time ;; needed for the eval of the prefix format | 5662 | time ;; needed for the eval of the prefix format |
| 5668 | (ts (if dotime (concat (if (stringp dotime) dotime "") txt))) | 5663 | (ts (if dotime (concat (if (stringp dotime) dotime "") txt))) |
| 5669 | (time-of-day (and dotime (org-get-time-of-day ts))) | 5664 | (time-of-day (and dotime (org-get-time-of-day ts))) |
| @@ -5704,6 +5699,7 @@ only the correctly processes TXT should be returned - this is used by | |||
| 5704 | ;; And finally add the text properties | 5699 | ;; And finally add the text properties |
| 5705 | (add-text-properties | 5700 | (add-text-properties |
| 5706 | 0 (length rtn) (list 'category (downcase category) | 5701 | 0 (length rtn) (list 'category (downcase category) |
| 5702 | 'tags tags | ||
| 5707 | 'prefix-length (- (length rtn) (length txt)) | 5703 | 'prefix-length (- (length rtn) (length txt)) |
| 5708 | 'time-of-day time-of-day | 5704 | 'time-of-day time-of-day |
| 5709 | 'dotime dotime) | 5705 | 'dotime dotime) |
| @@ -5732,7 +5728,7 @@ only the correctly processes TXT should be returned - this is used by | |||
| 5732 | (unless (and remove (member time have)) | 5728 | (unless (and remove (member time have)) |
| 5733 | (setq time (int-to-string time)) | 5729 | (setq time (int-to-string time)) |
| 5734 | (push (org-format-agenda-item | 5730 | (push (org-format-agenda-item |
| 5735 | nil string "" ;; FIXME: put a category for the grid? | 5731 | nil string "" nil ;; FIXME: put a category for the grid? |
| 5736 | (concat (substring time 0 -2) ":" (substring time -2))) | 5732 | (concat (substring time 0 -2) ":" (substring time -2))) |
| 5737 | new) | 5733 | new) |
| 5738 | (put-text-property | 5734 | (put-text-property |
| @@ -5746,11 +5742,12 @@ only the correctly processes TXT should be returned - this is used by | |||
| 5746 | The resulting form is returned and stored in the variable | 5742 | The resulting form is returned and stored in the variable |
| 5747 | `org-prefix-format-compiled'." | 5743 | `org-prefix-format-compiled'." |
| 5748 | (setq org-prefix-has-time nil) | 5744 | (setq org-prefix-has-time nil) |
| 5749 | (let ((start 0) varform vars var (s format) c f opt) | 5745 | (let ((start 0) varform vars var (s format)e c f opt) |
| 5750 | (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cts]\\)" | 5746 | (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cts]\\)" |
| 5751 | s start) | 5747 | s start) |
| 5752 | (setq var (cdr (assoc (match-string 4 s) | 5748 | (setq var (cdr (assoc (match-string 4 s) |
| 5753 | '(("c" . category) ("t" . time) ("s" . extra)))) | 5749 | '(("c" . category) ("t" . time) ("s" . extra) |
| 5750 | ("T" . tag)))) | ||
| 5754 | c (or (match-string 3 s) "") | 5751 | c (or (match-string 3 s) "") |
| 5755 | opt (match-beginning 1) | 5752 | opt (match-beginning 1) |
| 5756 | start (1+ (match-beginning 0))) | 5753 | start (1+ (match-beginning 0))) |
| @@ -5788,7 +5785,9 @@ HH:MM." | |||
| 5788 | (if (match-beginning 3) | 5785 | (if (match-beginning 3) |
| 5789 | (string-to-number (match-string 3 s)) | 5786 | (string-to-number (match-string 3 s)) |
| 5790 | 0))) | 5787 | 0))) |
| 5791 | (t1 (concat " " (int-to-string t0)))) | 5788 | (t1 (concat " " |
| 5789 | (if (< t0 100) "0" "") | ||
| 5790 | (int-to-string t0)))) | ||
| 5792 | (if string (concat (substring t1 -4 -2) ":" (substring t1 -2)) t0))))) | 5791 | (if string (concat (substring t1 -4 -2) ":" (substring t1 -2)) t0))))) |
| 5793 | 5792 | ||
| 5794 | (defun org-finalize-agenda-entries (list) | 5793 | (defun org-finalize-agenda-entries (list) |
| @@ -5842,6 +5841,14 @@ and by additional input from the age of a schedules or deadline entry." | |||
| 5842 | (let* ((pri (get-text-property (point-at-bol) 'priority))) | 5841 | (let* ((pri (get-text-property (point-at-bol) 'priority))) |
| 5843 | (message "Priority is %d" (if pri pri -1000)))) | 5842 | (message "Priority is %d" (if pri pri -1000)))) |
| 5844 | 5843 | ||
| 5844 | (defun org-agenda-show-tags () | ||
| 5845 | "Show the tags applicable to the current item." | ||
| 5846 | (interactive) | ||
| 5847 | (let* ((tags (get-text-property (point-at-bol) 'tags))) | ||
| 5848 | (if tags | ||
| 5849 | (message "Tags are :%s:" (mapconcat 'identity tags ":")) | ||
| 5850 | (message "No tags associated with this line")))) | ||
| 5851 | |||
| 5845 | (defun org-agenda-goto (&optional highlight) | 5852 | (defun org-agenda-goto (&optional highlight) |
| 5846 | "Go to the Org-mode file which contains the item at point." | 5853 | "Go to the Org-mode file which contains the item at point." |
| 5847 | (interactive) | 5854 | (interactive) |
| @@ -5954,7 +5961,7 @@ The new content of the line will be NEWHEAD (as modified by | |||
| 5954 | `equal' against all `org-hd-marker' text properties in the file. | 5961 | `equal' against all `org-hd-marker' text properties in the file. |
| 5955 | If FIXFACE is non-nil, the face of each item is modified acording to | 5962 | If FIXFACE is non-nil, the face of each item is modified acording to |
| 5956 | the new TODO state." | 5963 | the new TODO state." |
| 5957 | (let* (props m pl undone-face done-face finish new dotime cat) | 5964 | (let* (props m pl undone-face done-face finish new dotime cat tags) |
| 5958 | ; (setq newhead (org-format-agenda-item "x" newhead "x" nil 'noprefix)) | 5965 | ; (setq newhead (org-format-agenda-item "x" newhead "x" nil 'noprefix)) |
| 5959 | (save-excursion | 5966 | (save-excursion |
| 5960 | (goto-char (point-max)) | 5967 | (goto-char (point-max)) |
| @@ -5966,7 +5973,8 @@ the new TODO state." | |||
| 5966 | (setq props (text-properties-at (point)) | 5973 | (setq props (text-properties-at (point)) |
| 5967 | dotime (get-text-property (point) 'dotime) | 5974 | dotime (get-text-property (point) 'dotime) |
| 5968 | cat (get-text-property (point) 'category) | 5975 | cat (get-text-property (point) 'category) |
| 5969 | new (org-format-agenda-item "x" newhead cat dotime 'noprefix) | 5976 | tags (get-text-property (point) 'tags) |
| 5977 | new (org-format-agenda-item "x" newhead cat tags dotime 'noprefix) | ||
| 5970 | pl (get-text-property (point) 'prefix-length) | 5978 | pl (get-text-property (point) 'prefix-length) |
| 5971 | undone-face (get-text-property (point) 'undone-face) | 5979 | undone-face (get-text-property (point) 'undone-face) |
| 5972 | done-face (get-text-property (point) 'done-face)) | 5980 | done-face (get-text-property (point) 'done-face)) |
| @@ -6294,7 +6302,7 @@ d are included in the output." | |||
| 6294 | (if org-tags-match-list-sublevels | 6302 | (if org-tags-match-list-sublevels |
| 6295 | (make-string (1- level) ?.) "") | 6303 | (make-string (1- level) ?.) "") |
| 6296 | (org-get-heading)) | 6304 | (org-get-heading)) |
| 6297 | category)) | 6305 | category tags-list)) |
| 6298 | (goto-char lspos) | 6306 | (goto-char lspos) |
| 6299 | (setq marker (org-agenda-new-marker)) | 6307 | (setq marker (org-agenda-new-marker)) |
| 6300 | (add-text-properties | 6308 | (add-text-properties |
| @@ -6870,11 +6878,19 @@ If the file does not exist, an error is thrown." | |||
| 6870 | (setq cmd 'emacs) | 6878 | (setq cmd 'emacs) |
| 6871 | (setq cmd (or (cdr (assoc ext apps)) | 6879 | (setq cmd (or (cdr (assoc ext apps)) |
| 6872 | (cdr (assoc t apps))))) | 6880 | (cdr (assoc t apps))))) |
| 6881 | (when (eq cmd 'mailcap) | ||
| 6882 | (require 'mailcap) | ||
| 6883 | (mailcap-parse-mailcaps) | ||
| 6884 | (let* ((mime-type (mailcap-extension-to-mime (or ext ""))) | ||
| 6885 | (command (mailcap-mime-info mime-type))) | ||
| 6886 | (if (stringp command) | ||
| 6887 | (setq cmd command) | ||
| 6888 | (setq cmd 'emacs)))) | ||
| 6873 | (cond | 6889 | (cond |
| 6874 | ((and (stringp cmd) (not (string-match "^\\s-*$" cmd))) | 6890 | ((and (stringp cmd) (not (string-match "^\\s-*$" cmd))) |
| 6875 | (setq cmd (format cmd (concat "\"" file "\""))) | 6891 | (setq cmd (format cmd (concat "\"" file "\""))) |
| 6876 | (save-window-excursion | 6892 | (save-window-excursion |
| 6877 | (shell-command (concat cmd " & &")))) | 6893 | (shell-command (concat cmd " &")))) |
| 6878 | ((or (stringp cmd) | 6894 | ((or (stringp cmd) |
| 6879 | (eq cmd 'emacs)) | 6895 | (eq cmd 'emacs)) |
| 6880 | (unless (equal (file-truename file) (file-truename (buffer-file-name))) | 6896 | (unless (equal (file-truename file) (file-truename (buffer-file-name))) |
| @@ -7587,7 +7603,7 @@ This is being used to correctly align a single field after TAB or RET.") | |||
| 7587 | (while (< (setq i (1+ i)) maxfields) ;; Loop over all columns | 7603 | (while (< (setq i (1+ i)) maxfields) ;; Loop over all columns |
| 7588 | (setq column (mapcar (lambda (x) (or (nth i x) "")) fields)) | 7604 | (setq column (mapcar (lambda (x) (or (nth i x) "")) fields)) |
| 7589 | ;; maximum length | 7605 | ;; maximum length |
| 7590 | (push (apply 'max 1 (mapcar 'length column)) lengths) | 7606 | (push (apply 'max 1 (mapcar 'string-width column)) lengths) |
| 7591 | ;; compute the fraction stepwise, ignoring empty fields | 7607 | ;; compute the fraction stepwise, ignoring empty fields |
| 7592 | (setq cnt 0 frac 0.0) | 7608 | (setq cnt 0 frac 0.0) |
| 7593 | (mapcar | 7609 | (mapcar |
| @@ -7843,7 +7859,7 @@ This actually throws an error, so it aborts the current command." | |||
| 7843 | (if (looking-at "|[^|\n]+") | 7859 | (if (looking-at "|[^|\n]+") |
| 7844 | (let* ((pos (match-beginning 0)) | 7860 | (let* ((pos (match-beginning 0)) |
| 7845 | (match (match-string 0)) | 7861 | (match (match-string 0)) |
| 7846 | (len (length match))) | 7862 | (len (string-width match))) |
| 7847 | (replace-match (concat "|" (make-string (1- len) ?\ ))) | 7863 | (replace-match (concat "|" (make-string (1- len) ?\ ))) |
| 7848 | (goto-char (+ 2 pos)) | 7864 | (goto-char (+ 2 pos)) |
| 7849 | (substring match 1))))) | 7865 | (substring match 1))))) |
| @@ -8101,7 +8117,9 @@ With prefix ARG, insert below the current line." | |||
| 8101 | (interactive "P") | 8117 | (interactive "P") |
| 8102 | (if (not (org-at-table-p)) | 8118 | (if (not (org-at-table-p)) |
| 8103 | (error "Not at a table")) | 8119 | (error "Not at a table")) |
| 8104 | (let* ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol))) | 8120 | (let* ((line |
| 8121 | (org-expand-wide-chars | ||
| 8122 | (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) | ||
| 8105 | new) | 8123 | new) |
| 8106 | (if (string-match "^[ \t]*|-" line) | 8124 | (if (string-match "^[ \t]*|-" line) |
| 8107 | (setq new (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line)) | 8125 | (setq new (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line)) |
| @@ -8124,7 +8142,9 @@ With prefix ARG, insert above the current line." | |||
| 8124 | (interactive "P") | 8142 | (interactive "P") |
| 8125 | (if (not (org-at-table-p)) | 8143 | (if (not (org-at-table-p)) |
| 8126 | (error "Not at a table")) | 8144 | (error "Not at a table")) |
| 8127 | (let ((line (buffer-substring-no-properties (point-at-bol) (point-at-eol))) | 8145 | (let ((line |
| 8146 | (org-expand-wide-chars | ||
| 8147 | (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) | ||
| 8128 | (col (current-column)) | 8148 | (col (current-column)) |
| 8129 | start) | 8149 | start) |
| 8130 | (if (string-match "^[ \t]*|-" line) | 8150 | (if (string-match "^[ \t]*|-" line) |
| @@ -8143,9 +8163,19 @@ With prefix ARG, insert above the current line." | |||
| 8143 | (if (equal (char-before (point)) ?+) | 8163 | (if (equal (char-before (point)) ?+) |
| 8144 | (progn (backward-delete-char 1) (insert "|"))) | 8164 | (progn (backward-delete-char 1) (insert "|"))) |
| 8145 | (insert "\n") | 8165 | (insert "\n") |
| 8146 | (beginning-of-line 0) | 8166 | (beginning-of-line (if arg 1 -1)) |
| 8147 | (move-to-column col))) | 8167 | (move-to-column col))) |
| 8148 | 8168 | ||
| 8169 | (defun org-expand-wide-chars (s) | ||
| 8170 | "Expand wide characters to spaces." | ||
| 8171 | (let (w a) | ||
| 8172 | (mapconcat | ||
| 8173 | (lambda (x) | ||
| 8174 | (if (> (setq w (string-width (setq a (char-to-string x)))) 1) | ||
| 8175 | (make-string w ?\ ) | ||
| 8176 | a)) | ||
| 8177 | s ""))) | ||
| 8178 | |||
| 8149 | (defun org-table-kill-row () | 8179 | (defun org-table-kill-row () |
| 8150 | "Delete the current row or horizontal line from the table." | 8180 | "Delete the current row or horizontal line from the table." |
| 8151 | (interactive) | 8181 | (interactive) |
| @@ -8300,8 +8330,9 @@ blindly applies a recipe that works for simple tables." | |||
| 8300 | ;; insert a hline before first | 8330 | ;; insert a hline before first |
| 8301 | (goto-char beg) | 8331 | (goto-char beg) |
| 8302 | (org-table-insert-hline 'above) | 8332 | (org-table-insert-hline 'above) |
| 8333 | (beginning-of-line -1) | ||
| 8303 | ;; insert a hline after each line | 8334 | ;; insert a hline after each line |
| 8304 | (while (progn (beginning-of-line 2) (< (point) end)) | 8335 | (while (progn (beginning-of-line 3) (< (point) end)) |
| 8305 | (org-table-insert-hline)) | 8336 | (org-table-insert-hline)) |
| 8306 | (goto-char beg) | 8337 | (goto-char beg) |
| 8307 | (setq end (move-marker end (org-table-end))) | 8338 | (setq end (move-marker end (org-table-end))) |
| @@ -8390,7 +8421,7 @@ IF WIDTH is nil and LINES is non-nil, the string is forced into at most that | |||
| 8390 | many lines, whatever width that takes. | 8421 | many lines, whatever width that takes. |
| 8391 | The return value is a list of lines, without newlines at the end." | 8422 | The return value is a list of lines, without newlines at the end." |
| 8392 | (let* ((words (org-split-string string "[ \t\n]+")) | 8423 | (let* ((words (org-split-string string "[ \t\n]+")) |
| 8393 | (maxword (apply 'max (mapcar 'length words))) | 8424 | (maxword (apply 'max (mapcar 'string-width words))) |
| 8394 | w ll) | 8425 | w ll) |
| 8395 | (cond (width | 8426 | (cond (width |
| 8396 | (org-do-wrap words (max maxword width))) | 8427 | (org-do-wrap words (max maxword width))) |
| @@ -11130,10 +11161,10 @@ a time), or the day by one (if it does not contain a time)." | |||
| 11130 | 11161 | ||
| 11131 | ;; - Bindings in Org-mode map are currently | 11162 | ;; - Bindings in Org-mode map are currently |
| 11132 | ;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet | 11163 | ;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet |
| 11133 | ;; abcd fgh j lmnopqrstuvwxyz ? #$ -+*/= [] ; |,.<>~ \t necessary bindings | 11164 | ;; abcd fgh j lmnopqrstuvwxyz!? #$ -+*/= [] ; |,.<>~ \t necessary bindings |
| 11134 | ;; e (?) useful from outline-mode | 11165 | ;; e (?) useful from outline-mode |
| 11135 | ;; i k @ expendable from outline-mode | 11166 | ;; i k @ expendable from outline-mode |
| 11136 | ;; 0123456789 ! %^& ()_{} " `' free | 11167 | ;; 0123456789 %^& ()_{} " `' free |
| 11137 | 11168 | ||
| 11138 | ;; Make `C-c C-x' a prefix key | 11169 | ;; Make `C-c C-x' a prefix key |
| 11139 | (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) | 11170 | (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) |
| @@ -12116,3 +12147,25 @@ Show the heading too, if it is currently invisible." | |||
| 12116 | ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd | 12147 | ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd |
| 12117 | ;;; org.el ends here | 12148 | ;;; org.el ends here |
| 12118 | 12149 | ||
| 12150 | |||
| 12151 | (defun org-get-tags-at (&optional pos) | ||
| 12152 | "Get a list of all headline targs applicable at POS. | ||
| 12153 | POS defaults to point. If tags are inherited, the list contains | ||
| 12154 | the targets in the same sequence as the headlines appear, i.e. | ||
| 12155 | the tags of the current headline come last." | ||
| 12156 | (interactive) | ||
| 12157 | (let (tags) | ||
| 12158 | (save-excursion | ||
| 12159 | (goto-char (or pos (point))) | ||
| 12160 | (save-match-data | ||
| 12161 | (org-back-to-heading t) | ||
| 12162 | (condition-case nil | ||
| 12163 | (while t | ||
| 12164 | (if (looking-at "[^\r\n]+?:\\([a-zA-Z_:]+\\):[ \t]*\\([\n\r]\\|\\'\\)") | ||
| 12165 | (setq tags (append (org-split-string (match-string 1) ":") tags))) | ||
| 12166 | (or org-use-tag-inheritance (error "")) | ||
| 12167 | (org-up-heading-all 1)) | ||
| 12168 | (error nil)))) | ||
| 12169 | (message "%s" tags) | ||
| 12170 | tags)) | ||
| 12171 | |||