diff options
| author | Carsten Dominik | 2008-03-13 08:53:48 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2008-03-13 08:53:48 +0000 |
| commit | 0fc0f17869bb4d7f8ef303d6960665a0638b6912 (patch) | |
| tree | be90e811db84402db8223df5f0092857bd3da97b | |
| parent | 28a16a1bf0f8a302d13c30bfe49f785068edde95 (diff) | |
| download | emacs-0fc0f17869bb4d7f8ef303d6960665a0638b6912.tar.gz emacs-0fc0f17869bb4d7f8ef303d6960665a0638b6912.zip | |
New file
| -rw-r--r-- | lisp/ChangeLog | 126 | ||||
| -rw-r--r-- | lisp/textmodes/org-irc.el | 232 | ||||
| -rw-r--r-- | lisp/textmodes/org-mac-message.el | 77 |
3 files changed, 435 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 84300d9d5e8..a2cf0cc6ba5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,129 @@ | |||
| 1 | 2008-03-13 Carsten Dominik <dominik@science.uva.nl> | ||
| 2 | |||
| 3 | * textmodes/org.el (org-ctrl-c-star): Implement a missing branch | ||
| 4 | in the decision tree. | ||
| 5 | (org-select-remember-template): Cleaned the code. | ||
| 6 | (org-prepare-dblock): Added the extra :content parameter. | ||
| 7 | (org-write-agenda): New output type ".ics" files. | ||
| 8 | (org-write-agenda): Call `org-icalendar-verify-function', both for | ||
| 9 | time stamps and for TODO entries. | ||
| 10 | (org-agenda-collect-markers, org-create-marker-find-array) | ||
| 11 | (org-check-agenda-marker-table): New functions. | ||
| 12 | (org-agenda-marker-table): New variable. | ||
| 13 | (org-export-as-html): Revert the change that killed the html | ||
| 14 | buffer. Side effects first need to be studied carefully. | ||
| 15 | (org-get-tags-at): Fix the structure of the condition-case | ||
| 16 | statement. | ||
| 17 | (org-ts-regexp0, org-repeat-re, org-display-custom-time) | ||
| 18 | (org-timestamp-change): Fix regulear expressions to swallow the | ||
| 19 | extra character for repeat-shift control. | ||
| 20 | (org-auto-repeat-maybe): Implement the new repeater mechanisms. | ||
| 21 | (org-get-legal-level): Aliased to `org-get-valid-level'. | ||
| 22 | (org-dblock-write:clocktable): Added a :link parameter, linking | ||
| 23 | headlines to their location in the Org agenda files. | ||
| 24 | (org-get-tags-at): Bugfix: prevent `org-back-to-heading' from | ||
| 25 | throwing an error when getting tags before headlines. | ||
| 26 | (org-timestamp-change, org-modify-ts-extra) | ||
| 27 | (org-ts-regexp1): Fix timestamp editing. | ||
| 28 | (org-agenda-custom-commands-local-options): New constant. | ||
| 29 | (org-agenda-custom-commands): Use | ||
| 30 | `org-agenda-custom-commands-local-options' to improve customize | ||
| 31 | type. "htmlize": Removed hack to fix face problem with htmlize, | ||
| 32 | it no longer seem necessary. | ||
| 33 | (org-follow-link-hook): New hook. | ||
| 34 | (org-agenda-custom-commands): Added "Component" as a tag for each | ||
| 35 | item in a command serie. | ||
| 36 | (org-open-at-point): Run `org-follow-link-hook'. | ||
| 37 | (org-agenda-schedule): Bugfix: don't display marker type when it | ||
| 38 | is `nil'. | ||
| 39 | (org-store-link): org-irc required. | ||
| 40 | (org-set-regexps-and-options): Parse the new logging options. | ||
| 41 | (org-extract-log-state-settings): New function. | ||
| 42 | (org-todo): Handle the new ways of recording state change stuff. | ||
| 43 | (org-local-logging): New function. | ||
| 44 | (org-columns-open-link): Fixed bug with opening link in column | ||
| 45 | view. | ||
| 46 | (org-local-logging): New function | ||
| 47 | (org-todo): Make sure that LOGGING properties are honoured. | ||
| 48 | (org-todo-keywords): Improve docstring. | ||
| 49 | (org-startup-options): Cleanup startup options. | ||
| 50 | (org-set-regexps-and-options): Process the "!" markers. | ||
| 51 | (org-todo): Respect the new logging stuff. | ||
| 52 | (org-log-note-how): New variable. | ||
| 53 | (org-add-log-maybe): New parameter HOW that defines how logging | ||
| 54 | should be done and also overrides PURPOSE. Add a docstring. | ||
| 55 | (org-add-log-note): Check if we really need to ask for a note. | ||
| 56 | (org-get-current-options): Digest the new keyword. | ||
| 57 | (org-agenda-reset-markers): Renamed from | ||
| 58 | `org-agenda-maybe-reset-markers'. FORCE argument removed. | ||
| 59 | (org-diary, org-agenda-quit, org-prepare-agenda): Call the renamed | ||
| 60 | function, without force argument. | ||
| 61 | (org-buffer-property-keys): Bind local variables s and p. | ||
| 62 | (org-make-tags-matcher): Allow "" to match an empty or | ||
| 63 | non-existent property value. | ||
| 64 | (org-export-as-html): Join unsorted lists when they directly | ||
| 65 | follow each other. Such lists may be created by headlines that | ||
| 66 | are converted to lists. | ||
| 67 | (org-nofm-to-completion): New function. | ||
| 68 | (org-export-as-html): Use :html-extension instead of | ||
| 69 | org-export-html-extension. | ||
| 70 | (org-store-link): Support for links from `rmail-summary-mode'. | ||
| 71 | (org-columns-new, org-complete, org-set-property): Set the | ||
| 72 | `include-columns' argument in the call to | ||
| 73 | `org-buffer-property-keys'. | ||
| 74 | (org-buffer-property-keys): New argument `include-columns', to | ||
| 75 | include properties expected by any of the COLUMS formats in the | ||
| 76 | current buffer. | ||
| 77 | (org-cleaned-string-for-export): Get rid of drawers first, so that | ||
| 78 | they will be removed also in the text before the first headline. | ||
| 79 | (org-clock-report): Show the clocktable when found. | ||
| 80 | (org-refile): Fix positioning bug when `org-reverse-note-order' is | ||
| 81 | nil. | ||
| 82 | (org-version): With prefix argument, insert `org-version' at | ||
| 83 | point. | ||
| 84 | (org-agenda-goto): Recenter the window after finding the target | ||
| 85 | location, to make sure the correct position will be displayed. | ||
| 86 | (org-agenda-get-deadlines): Don't scale priority with the warning | ||
| 87 | period. | ||
| 88 | (org-insert-heading): Don't break line in the middle of the line. | ||
| 89 | (org-agenda-get-deadlines): Allow `org-deadline-warning-days' to | ||
| 90 | be 0. | ||
| 91 | (org-update-checkbox-count): Revamped to deal with hierarchical | ||
| 92 | beckboxes. This was a patch from Miguel A. Figueroa-Villanueva. | ||
| 93 | (org-remove-timestamp-with-keyword): New function. | ||
| 94 | (org-schedule, org-deadline): Use | ||
| 95 | `org-remove-timestamp-with-keyword' to make sure all such time | ||
| 96 | stamps are removed. | ||
| 97 | (org-mode): Support for `align'. | ||
| 98 | (org-agenda-get-deadlines): Make sure priorities increase as the | ||
| 99 | due date approaches and is passed. | ||
| 100 | (org-remember-apply-template): Fixed problem with tags that | ||
| 101 | contain "_" or "@". | ||
| 102 | (org-make-link-regexps): Improve the regular expression for plain | ||
| 103 | links. | ||
| 104 | (org-agenda-get-closed): List each clocking entry. | ||
| 105 | (org-set-tags): Only tabify before tags if indent-tabs-mode is t. | ||
| 106 | (org-special-ctrl-k): New option. | ||
| 107 | (org-kill-line): New function. | ||
| 108 | (org-archive-all-done): Fixed incorrect number of stars in regexp. | ||
| 109 | (org-refile-get-location): New function. | ||
| 110 | (org-refile-goto-last-stored): New function. | ||
| 111 | (org-global-tags-completion-table): Add the value of org-tag-alist | ||
| 112 | in each buffer, to make sure that also unused tags will be | ||
| 113 | available for completion. | ||
| 114 | (org-columns-edit-value) | ||
| 115 | (org-columns-next-allowed-value): Only update if not in agenda. | ||
| 116 | (org-clocktable-steps): New function. | ||
| 117 | (org-dblock-write:clocktable): Call `org-clocktable-steps'. | ||
| 118 | (org-archive-subtree): Add the outline tree context as a property. | ||
| 119 | (org-closest-date): New optional argument `prefer'. | ||
| 120 | (org-goto-auto-isearch): New option. | ||
| 121 | (org-goto-map, org-get-location): Implement auto-isearch. | ||
| 122 | (org-goto-local-auto-isearch-map): New variable. | ||
| 123 | (org-goto-local-search-forward-headings) | ||
| 124 | (org-goto-local-auto-isearch): New functions | ||
| 125 | |||
| 126 | |||
| 1 | 2008-03-13 Dan Nicolaescu <dann@ics.uci.edu> | 127 | 2008-03-13 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 128 | ||
| 3 | * font-lock.el (font-lock-comment-face): Set the foreground for | 129 | * font-lock.el (font-lock-comment-face): Set the foreground for |
diff --git a/lisp/textmodes/org-irc.el b/lisp/textmodes/org-irc.el new file mode 100644 index 00000000000..8bbd5000f26 --- /dev/null +++ b/lisp/textmodes/org-irc.el | |||
| @@ -0,0 +1,232 @@ | |||
| 1 | ;;; org-irc.el --- Store links to IRC sessions | ||
| 2 | ;; | ||
| 3 | ;; Copyright (C) 2008 Free Software Foundation, Inc. | ||
| 4 | ;; | ||
| 5 | ;; Author: Philip Jackson <emacs@shellarchive.co.uk> | ||
| 6 | ;; Keywords: erc, irc, link, org | ||
| 7 | ;; Version: 1.3 | ||
| 8 | ;; | ||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | ;; | ||
| 11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 14 | ;; any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 23 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 24 | ;; Boston, MA 02110-1301, USA. | ||
| 25 | ;; | ||
| 26 | ;;; Commentary: | ||
| 27 | ;; | ||
| 28 | ;; Link to an IRC session. Only ERC has been implemented at the | ||
| 29 | ;; moment. | ||
| 30 | ;; | ||
| 31 | ;; This file is loaded by default whenever org.el is loaded. Please | ||
| 32 | ;; customize the variable `org-default-extensions' to select extensions | ||
| 33 | ;; you would like to use, and to deselect those which you don't want. | ||
| 34 | ;; | ||
| 35 | ;; Please note that at the moment only ERC is supported. Other clients | ||
| 36 | ;; shouldn't be diffficult to add though. | ||
| 37 | ;; | ||
| 38 | ;; Then set `org-irc-link-to-logs' to non-nil if you would like a | ||
| 39 | ;; file:/ type link to be created to the current line in the logs or | ||
| 40 | ;; to t if you would like to create an irc:/ style link. | ||
| 41 | ;; | ||
| 42 | ;; Links within an org buffer might look like this: | ||
| 43 | ;; | ||
| 44 | ;; [[irc:/irc.freenode.net/#emacs/bob][chat with bob in #emacs on freenode]] | ||
| 45 | ;; [[irc:/irc.freenode.net/#emacs][#emacs on freenode]] | ||
| 46 | ;; [[irc:/irc.freenode.net/]] | ||
| 47 | ;; | ||
| 48 | ;; If, when the resulting link is visited, there is no connection to a | ||
| 49 | ;; requested server then one will be created. | ||
| 50 | ;; | ||
| 51 | ;;; Code: | ||
| 52 | |||
| 53 | |||
| 54 | (eval-when-compile | ||
| 55 | (require 'cl)) | ||
| 56 | |||
| 57 | (require 'org) | ||
| 58 | (require 'erc) | ||
| 59 | (require 'erc-log) | ||
| 60 | |||
| 61 | (defvar org-irc-client 'erc | ||
| 62 | "The IRC client to act on") | ||
| 63 | (defvar org-irc-link-to-logs nil | ||
| 64 | "non-nil will store a link to the logs, nil will store an irc: style link") | ||
| 65 | |||
| 66 | (defvar erc-default-port) ; dynamically scoped from erc.el | ||
| 67 | (defvar erc-session-port) ; dynamically scoped form erc-backend.el | ||
| 68 | (defvar erc-server-announced-name) ; dynamically scoped form erc-backend.el | ||
| 69 | |||
| 70 | ;; Generic functions/config (extend these for other clients) | ||
| 71 | |||
| 72 | (add-to-list 'org-store-link-functions | ||
| 73 | 'org-irc-store-link) | ||
| 74 | |||
| 75 | (org-add-link-type "irc" 'org-irc-visit nil) | ||
| 76 | |||
| 77 | (defun org-irc-visit (link) | ||
| 78 | "Dispatch to the correct visit function based on the client" | ||
| 79 | (let ((link (org-irc-parse-link link))) | ||
| 80 | (cond | ||
| 81 | ((eq org-irc-client 'erc) | ||
| 82 | (org-irc-visit-erc link)) | ||
| 83 | (t | ||
| 84 | (error "erc only known client"))))) | ||
| 85 | |||
| 86 | (defun org-irc-parse-link (link) | ||
| 87 | "Get a of irc link attributes where `link' looks like | ||
| 88 | server:port/chan/user (port, chan and user being optional)." | ||
| 89 | (let* ((parts (split-string link "/" t)) | ||
| 90 | (len (length parts))) | ||
| 91 | (when (or (< len 1) (> len 3)) | ||
| 92 | (error "Failed to parse link needed 1-3 parts, got %d." len)) | ||
| 93 | (setcar parts (split-string (car parts) ":" t)) | ||
| 94 | parts)) | ||
| 95 | |||
| 96 | ;;;###autoload | ||
| 97 | (defun org-irc-store-link () | ||
| 98 | "Dispatch to the appropreate function to store a link to | ||
| 99 | something IRC related" | ||
| 100 | (cond | ||
| 101 | ((eq major-mode 'erc-mode) | ||
| 102 | (org-irc-erc-store-link)))) | ||
| 103 | |||
| 104 | (defun org-irc-elipsify-description (string &optional after) | ||
| 105 | "Strip starting and ending whitespace and replace any chars | ||
| 106 | that appear after the value in `after' with '...'" | ||
| 107 | (let* ((after (number-to-string (or after 30))) | ||
| 108 | (replace-map (list (cons "^[ \t]*" "") | ||
| 109 | (cons "[ \t]*$" "") | ||
| 110 | (cons (concat "^\\(.\\{" after | ||
| 111 | "\\}\\).*") "\\1...")))) | ||
| 112 | (mapc (lambda (x) | ||
| 113 | (when (string-match (car x) string) | ||
| 114 | (setq string (replace-match (cdr x) nil nil string)))) | ||
| 115 | replace-map) | ||
| 116 | string)) | ||
| 117 | |||
| 118 | ;; ERC specific functions | ||
| 119 | |||
| 120 | (defun org-irc-erc-get-line-from-log (erc-line) | ||
| 121 | "Find the most suitable line to link to from the erc logs. If | ||
| 122 | the user is on the erc-prompt then search backward for the first | ||
| 123 | non-blank line, otherwise return the current line. The result is | ||
| 124 | a cons of the filename and search string." | ||
| 125 | (erc-save-buffer-in-logs) | ||
| 126 | (with-current-buffer (find-file-noselect (erc-current-logfile)) | ||
| 127 | (goto-char (point-max)) | ||
| 128 | (list | ||
| 129 | (abbreviate-file-name buffer-file-name) | ||
| 130 | ;; can we get a '::' part? | ||
| 131 | (if (string= erc-line (erc-prompt)) | ||
| 132 | (progn | ||
| 133 | (goto-char (point-at-bol)) | ||
| 134 | (when (search-backward-regexp "^[^ ]" nil t) | ||
| 135 | (buffer-substring-no-properties (point-at-bol) | ||
| 136 | (point-at-eol)))) | ||
| 137 | (when (search-backward erc-line nil t) | ||
| 138 | (buffer-substring-no-properties (point-at-bol) | ||
| 139 | (point-at-eol))))))) | ||
| 140 | |||
| 141 | (defun org-irc-erc-store-link () | ||
| 142 | "Depending on the variable `org-irc-link-to-logs' store either | ||
| 143 | a link to the log file for the current session or an irc: link to | ||
| 144 | the session itself." | ||
| 145 | (if org-irc-link-to-logs | ||
| 146 | (let* ((erc-line (buffer-substring-no-properties | ||
| 147 | (point-at-bol) (point-at-eol))) | ||
| 148 | (parsed-line (org-irc-erc-get-line-from-log erc-line))) | ||
| 149 | (if (erc-logging-enabled nil) | ||
| 150 | (progn | ||
| 151 | (org-store-link-props | ||
| 152 | :type "file" | ||
| 153 | :description (concat "'" (org-irc-elipsify-description | ||
| 154 | (cadr parsed-line) 20) | ||
| 155 | "' from an IRC conversation") | ||
| 156 | :link (concat "file:" (car parsed-line) "::" | ||
| 157 | (cadr parsed-line))) | ||
| 158 | t) | ||
| 159 | (error "This ERC session is not being logged"))) | ||
| 160 | (let* ((link-text (org-irc-get-erc-link)) | ||
| 161 | (link (org-irc-parse-link link-text))) | ||
| 162 | (if link-text | ||
| 163 | (progn | ||
| 164 | (org-store-link-props | ||
| 165 | :type "irc" | ||
| 166 | :link (org-make-link "irc:/" link-text) | ||
| 167 | :description (concat "irc session '" link-text "'") | ||
| 168 | :server (car (car link)) | ||
| 169 | :port (or (cadr (pop link)) erc-default-port) | ||
| 170 | :nick (pop link)) | ||
| 171 | t) | ||
| 172 | (error "Failed to create ('irc:/' style) ERC link"))))) | ||
| 173 | |||
| 174 | (defun org-irc-get-erc-link () | ||
| 175 | "Return an org compatible irc:/ link from an ERC buffer" | ||
| 176 | (let ((link (concat erc-server-announced-name ":" | ||
| 177 | (number-to-string erc-session-port)))) | ||
| 178 | (concat link "/" | ||
| 179 | (if (and (erc-default-target) | ||
| 180 | (erc-channel-p (erc-default-target)) | ||
| 181 | (car (get-text-property (point) 'erc-data))) | ||
| 182 | ;; we can get a nick | ||
| 183 | (let ((nick (car (get-text-property (point) 'erc-data)))) | ||
| 184 | (concat (erc-default-target) "/" nick)) | ||
| 185 | (erc-default-target))))) | ||
| 186 | |||
| 187 | (defun org-irc-visit-erc (link) | ||
| 188 | "Visit an ERC buffer based on criteria from the followed link" | ||
| 189 | (let* ((server (car (car link))) | ||
| 190 | (port (or (cadr (pop link)) erc-default-port)) | ||
| 191 | (server-buffer) | ||
| 192 | (buffer-list | ||
| 193 | (erc-buffer-filter | ||
| 194 | (lambda nil | ||
| 195 | (let ((tmp-server-buf (erc-server-buffer))) | ||
| 196 | (and tmp-server-buf | ||
| 197 | (with-current-buffer tmp-server-buf | ||
| 198 | (and | ||
| 199 | (string= erc-session-port port) | ||
| 200 | (string= erc-server-announced-name server) | ||
| 201 | (setq server-buffer tmp-server-buf))))))))) | ||
| 202 | (if buffer-list | ||
| 203 | (let ((chan-name (pop link))) | ||
| 204 | ;; if we got a channel name then switch to it or join it | ||
| 205 | (if chan-name | ||
| 206 | (let ((chan-buf (find-if | ||
| 207 | (lambda (x) | ||
| 208 | (string= (buffer-name x) chan-name)) | ||
| 209 | buffer-list))) | ||
| 210 | (if chan-buf | ||
| 211 | (progn | ||
| 212 | (switch-to-buffer chan-buf) | ||
| 213 | ;; if we got a nick, and they're in the chan, | ||
| 214 | ;; then start a chat with them | ||
| 215 | (let ((nick (pop link))) | ||
| 216 | (when nick | ||
| 217 | (if (find nick (erc-get-server-nickname-list) | ||
| 218 | :test 'string=) | ||
| 219 | (progn | ||
| 220 | (goto-char (point-max)) | ||
| 221 | (insert (concat nick ": "))) | ||
| 222 | (error "%s not found in %s" nick chan-name))))) | ||
| 223 | (progn | ||
| 224 | (switch-to-buffer server-buffer) | ||
| 225 | (erc-cmd-JOIN chan-name)))) | ||
| 226 | (switch-to-buffer server-buffer))) | ||
| 227 | ;; no server match, make new connection | ||
| 228 | (erc-select :server server :port port)))) | ||
| 229 | |||
| 230 | (provide 'org-irc) | ||
| 231 | |||
| 232 | ;;; org-irc.el ends here | ||
diff --git a/lisp/textmodes/org-mac-message.el b/lisp/textmodes/org-mac-message.el new file mode 100644 index 00000000000..1e9fabc8862 --- /dev/null +++ b/lisp/textmodes/org-mac-message.el | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | ;;; org-mac-message.el - Support for links to Apple Mail messages by Message-ID | ||
| 2 | ;; Carstens outline-mode for keeping track of everything. | ||
| 3 | ;; Copyright (C) 2008 Free Software Foundation, Inc. | ||
| 4 | ;; | ||
| 5 | ;; Author: John Wiegey <johnw@gnu.org> | ||
| 6 | ;; Version: 1.2 | ||
| 7 | ;; Keywords: outlines, hypermedia, calendar, wp | ||
| 8 | ;; | ||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | ;; | ||
| 11 | ;; Emacs is free software; you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 14 | ;; any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 23 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 24 | ;; Boston, MA 02110-1301, USA. | ||
| 25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 26 | |||
| 27 | (require 'org) | ||
| 28 | |||
| 29 | (org-add-link-type "message" 'org-mac-message-open) | ||
| 30 | |||
| 31 | (declare-function do-applescript "mac.c" (string)) | ||
| 32 | (unless (fboundp 'do-applescript) | ||
| 33 | ;; Need to fake this using shell-command-to-string | ||
| 34 | (defun do-applescript (script) | ||
| 35 | (let (start cmd return) | ||
| 36 | (while (string-match "\n" script) | ||
| 37 | (setq script (replace-match "\r" t t script))) | ||
| 38 | (while (string-match "'" script start) | ||
| 39 | (setq start (+ 2 (match-beginning 0)) | ||
| 40 | script (replace-match "\\'" t t script))) | ||
| 41 | (setq cmd (concat "osascript -e '" script "'")) | ||
| 42 | (setq return (shell-command-to-string cmd)) | ||
| 43 | (concat "\"" (org-trim return) "\"")))) | ||
| 44 | |||
| 45 | (defun org-mac-message-open (message-id) | ||
| 46 | "Visit the message with the given Message-ID. | ||
| 47 | This will use the command `open' with the message url." | ||
| 48 | (start-process (concat "open message:" message-id) nil | ||
| 49 | "open" (concat "message://<" (substring message-id 2) ">"))) | ||
| 50 | |||
| 51 | (defun org-mac-message-insert-link () | ||
| 52 | "Insert a link to the messages currently selected in Apple Mail. | ||
| 53 | This will use applescript to get the message-id and the subject of the | ||
| 54 | active mail in AppleMail and make a link out of it." | ||
| 55 | (interactive) | ||
| 56 | (insert (org-mac-message-get-link))) | ||
| 57 | |||
| 58 | (defun org-mac-message-get-link () | ||
| 59 | "Insert a link to the messages currently selected in Apple Mail. | ||
| 60 | This will use applescript to get the message-id and the subject of the | ||
| 61 | active mail in AppleMail and make a link out of it." | ||
| 62 | (let ((subject (do-applescript "tell application \"Mail\" | ||
| 63 | set theMessages to selection | ||
| 64 | subject of beginning of theMessages | ||
| 65 | end tell")) | ||
| 66 | (message-id (do-applescript "tell application \"Mail\" | ||
| 67 | set theMessages to selection | ||
| 68 | message id of beginning of theMessages | ||
| 69 | end tell"))) | ||
| 70 | (org-make-link-string | ||
| 71 | (concat "message://" | ||
| 72 | (substring message-id 1 (1- (length message-id)))) | ||
| 73 | (substring subject 1 (1- (length subject)))))) | ||
| 74 | |||
| 75 | (provide 'org-mac-message) | ||
| 76 | |||
| 77 | ;;; org-mac-message.el ends here | ||