]> git.eshelyaron.com Git - emacs.git/commitdiff
New file
authorCarsten Dominik <dominik@science.uva.nl>
Thu, 13 Mar 2008 08:53:48 +0000 (08:53 +0000)
committerCarsten Dominik <dominik@science.uva.nl>
Thu, 13 Mar 2008 08:53:48 +0000 (08:53 +0000)
lisp/ChangeLog
lisp/textmodes/org-irc.el [new file with mode: 0644]
lisp/textmodes/org-mac-message.el [new file with mode: 0644]

index 84300d9d5e8e37d0ea15288e366a8de948adfe11..a2cf0cc6ba5a4fce38cccb05f845ee54ef9f1f2e 100644 (file)
@@ -1,3 +1,129 @@
+2008-03-13  Carsten Dominik  <dominik@science.uva.nl>
+
+       * textmodes/org.el (org-ctrl-c-star): Implement a missing branch
+       in the decision tree.
+       (org-select-remember-template): Cleaned the code.
+       (org-prepare-dblock): Added the extra :content parameter.
+       (org-write-agenda): New output type ".ics" files.
+       (org-write-agenda): Call `org-icalendar-verify-function', both for
+       time stamps and for TODO entries.
+       (org-agenda-collect-markers, org-create-marker-find-array)
+       (org-check-agenda-marker-table): New functions.
+       (org-agenda-marker-table): New variable.
+       (org-export-as-html): Revert the change that killed the html
+       buffer.  Side effects first need to be studied carefully.
+       (org-get-tags-at): Fix the structure of the condition-case
+       statement.
+       (org-ts-regexp0, org-repeat-re, org-display-custom-time)
+       (org-timestamp-change): Fix regulear expressions to swallow the
+       extra character for repeat-shift control.
+       (org-auto-repeat-maybe): Implement the new repeater mechanisms.
+       (org-get-legal-level): Aliased to `org-get-valid-level'.
+       (org-dblock-write:clocktable): Added a :link parameter, linking
+       headlines to their location in the Org agenda files.
+       (org-get-tags-at): Bugfix: prevent `org-back-to-heading' from
+       throwing an error when getting tags before headlines.
+       (org-timestamp-change, org-modify-ts-extra)
+       (org-ts-regexp1): Fix timestamp editing.
+       (org-agenda-custom-commands-local-options): New constant.
+       (org-agenda-custom-commands): Use
+       `org-agenda-custom-commands-local-options' to improve customize
+       type.  "htmlize": Removed hack to fix face problem with htmlize,
+       it no longer seem necessary.
+       (org-follow-link-hook): New hook.
+       (org-agenda-custom-commands): Added "Component" as a tag for each
+       item in a command serie.
+       (org-open-at-point): Run `org-follow-link-hook'.
+       (org-agenda-schedule): Bugfix: don't display marker type when it
+       is `nil'.
+       (org-store-link): org-irc required.
+       (org-set-regexps-and-options): Parse the new logging options.
+       (org-extract-log-state-settings): New function.
+       (org-todo): Handle the new ways of recording state change stuff.
+       (org-local-logging): New function.
+       (org-columns-open-link): Fixed bug with opening link in column
+       view.
+       (org-local-logging): New function
+       (org-todo): Make sure that LOGGING properties are honoured.
+       (org-todo-keywords): Improve docstring.
+       (org-startup-options): Cleanup startup options.
+       (org-set-regexps-and-options): Process the "!" markers.
+       (org-todo): Respect the new logging stuff.
+       (org-log-note-how): New variable.
+       (org-add-log-maybe): New parameter HOW that defines how logging
+       should be done and also overrides PURPOSE.  Add a docstring.
+       (org-add-log-note): Check if we really need to ask for a note.
+       (org-get-current-options): Digest the new keyword.
+       (org-agenda-reset-markers): Renamed from
+       `org-agenda-maybe-reset-markers'.  FORCE argument removed.
+       (org-diary, org-agenda-quit, org-prepare-agenda): Call the renamed
+       function, without force argument.
+       (org-buffer-property-keys): Bind local variables s and p.
+       (org-make-tags-matcher): Allow "" to match an empty or
+       non-existent property value.
+       (org-export-as-html): Join unsorted lists when they directly
+       follow each other.  Such lists may be created by headlines that
+       are converted to lists.
+       (org-nofm-to-completion): New function.
+       (org-export-as-html): Use :html-extension instead of
+       org-export-html-extension.
+       (org-store-link): Support for links from `rmail-summary-mode'.
+       (org-columns-new, org-complete, org-set-property): Set the
+       `include-columns' argument in the call to
+       `org-buffer-property-keys'.
+       (org-buffer-property-keys): New argument `include-columns', to
+       include properties expected by any of the COLUMS formats in the
+       current buffer.
+       (org-cleaned-string-for-export): Get rid of drawers first, so that
+       they will be removed also in the text before the first headline.
+       (org-clock-report): Show the clocktable when found.
+       (org-refile): Fix positioning bug when `org-reverse-note-order' is
+       nil.
+       (org-version): With prefix argument, insert `org-version' at
+       point.
+       (org-agenda-goto): Recenter the window after finding the target
+       location, to make sure the correct position will be displayed.
+       (org-agenda-get-deadlines): Don't scale priority with the warning
+       period.
+       (org-insert-heading): Don't break line in the middle of the line.
+       (org-agenda-get-deadlines): Allow `org-deadline-warning-days' to
+       be 0.
+       (org-update-checkbox-count): Revamped to deal with hierarchical
+       beckboxes.  This was a patch from Miguel A. Figueroa-Villanueva.
+       (org-remove-timestamp-with-keyword): New function.
+       (org-schedule, org-deadline): Use
+       `org-remove-timestamp-with-keyword' to make sure all such time
+       stamps are removed.
+       (org-mode): Support for `align'.
+       (org-agenda-get-deadlines): Make sure priorities increase as the
+       due date approaches and is passed.
+       (org-remember-apply-template): Fixed problem with tags that
+       contain "_" or "@".
+       (org-make-link-regexps): Improve the regular expression for plain
+       links.
+       (org-agenda-get-closed): List each clocking entry.
+       (org-set-tags): Only tabify before tags if indent-tabs-mode is t.
+       (org-special-ctrl-k): New option.
+       (org-kill-line): New function.
+       (org-archive-all-done): Fixed incorrect number of stars in regexp.
+       (org-refile-get-location): New function.
+       (org-refile-goto-last-stored): New function.
+       (org-global-tags-completion-table): Add the value of org-tag-alist
+       in each buffer, to make sure that also unused tags will be
+       available for completion.
+       (org-columns-edit-value)
+       (org-columns-next-allowed-value): Only update if not in agenda.
+       (org-clocktable-steps): New function.
+       (org-dblock-write:clocktable): Call `org-clocktable-steps'.
+       (org-archive-subtree): Add the outline tree context as a property.
+       (org-closest-date): New optional argument `prefer'.
+       (org-goto-auto-isearch): New option.
+       (org-goto-map, org-get-location): Implement auto-isearch.
+       (org-goto-local-auto-isearch-map): New variable.
+       (org-goto-local-search-forward-headings)
+       (org-goto-local-auto-isearch): New functions
+
+
 2008-03-13  Dan Nicolaescu  <dann@ics.uci.edu>
 
        * 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 (file)
index 0000000..8bbd500
--- /dev/null
@@ -0,0 +1,232 @@
+;;; org-irc.el --- Store links to IRC sessions
+;;
+;; Copyright (C) 2008  Free Software Foundation, Inc.
+;;
+;; Author: Philip Jackson <emacs@shellarchive.co.uk>
+;; Keywords: erc, irc, link, org
+;; Version: 1.3
+;;
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+;;
+;;; Commentary:
+;;
+;; Link to an IRC session. Only ERC has been implemented at the
+;; moment.
+;;
+;; This file is loaded by default whenever org.el is loaded.  Please
+;; customize the variable `org-default-extensions' to select extensions
+;; you would like to use, and to deselect those which you don't want.
+;;
+;; Please note that at the moment only ERC is supported. Other clients
+;; shouldn't be diffficult to add though.
+;;
+;; Then set `org-irc-link-to-logs' to non-nil if you would like a
+;; file:/ type link to be created to the current line in the logs or
+;; to t if you would like to create an irc:/ style link.
+;;
+;; Links within an org buffer might look like this:
+;;
+;; [[irc:/irc.freenode.net/#emacs/bob][chat with bob in #emacs on freenode]]
+;; [[irc:/irc.freenode.net/#emacs][#emacs on freenode]]
+;; [[irc:/irc.freenode.net/]]
+;;
+;; If, when the resulting link is visited, there is no connection to a
+;; requested server then one will be created.
+;;
+;;; Code:
+
+
+(eval-when-compile
+  (require 'cl))
+
+(require 'org)
+(require 'erc)
+(require 'erc-log)
+
+(defvar org-irc-client 'erc
+  "The IRC client to act on")
+(defvar org-irc-link-to-logs nil
+  "non-nil will store a link to the logs, nil will store an irc: style link")
+
+(defvar erc-default-port) ; dynamically scoped from erc.el
+(defvar erc-session-port) ; dynamically scoped form erc-backend.el
+(defvar erc-server-announced-name) ; dynamically scoped form erc-backend.el
+
+;; Generic functions/config (extend these for other clients)
+
+(add-to-list 'org-store-link-functions
+             'org-irc-store-link)
+
+(org-add-link-type "irc" 'org-irc-visit nil)
+
+(defun org-irc-visit (link)
+  "Dispatch to the correct visit function based on the client"
+  (let ((link (org-irc-parse-link link)))
+    (cond
+      ((eq org-irc-client 'erc)
+       (org-irc-visit-erc link))
+      (t
+       (error "erc only known client")))))
+
+(defun org-irc-parse-link (link)
+  "Get a of irc link attributes where `link' looks like
+server:port/chan/user (port, chan and user being optional)."
+  (let* ((parts (split-string link "/" t))
+         (len (length parts)))
+    (when (or (< len 1) (> len 3))
+      (error "Failed to parse link needed 1-3 parts, got %d." len))
+    (setcar parts (split-string (car parts) ":" t))
+    parts))
+
+;;;###autoload
+(defun org-irc-store-link ()
+  "Dispatch to the appropreate function to store a link to
+something IRC related"
+  (cond
+    ((eq major-mode 'erc-mode)
+     (org-irc-erc-store-link))))
+
+(defun org-irc-elipsify-description (string &optional after)
+  "Strip starting and ending whitespace and replace any chars
+that appear after the value in `after' with '...'"
+  (let* ((after (number-to-string (or after 30)))
+         (replace-map (list (cons "^[ \t]*" "")
+                            (cons "[ \t]*$" "")
+                            (cons (concat "^\\(.\\{" after
+                                          "\\}\\).*") "\\1..."))))
+    (mapc (lambda (x)
+            (when (string-match (car x) string)
+              (setq string (replace-match (cdr x) nil nil string))))
+          replace-map)
+    string))
+
+;; ERC specific functions
+
+(defun org-irc-erc-get-line-from-log (erc-line)
+  "Find the most suitable line to link to from the erc logs. If
+the user is on the erc-prompt then search backward for the first
+non-blank line, otherwise return the current line. The result is
+a cons of the filename and search string."
+  (erc-save-buffer-in-logs)
+  (with-current-buffer (find-file-noselect (erc-current-logfile))
+    (goto-char (point-max))
+    (list
+     (abbreviate-file-name buffer-file-name)
+     ;; can we get a '::' part?
+     (if (string= erc-line (erc-prompt))
+         (progn
+           (goto-char (point-at-bol))
+           (when (search-backward-regexp "^[^  ]" nil t)
+             (buffer-substring-no-properties (point-at-bol)
+                                             (point-at-eol))))
+         (when (search-backward erc-line nil t)
+           (buffer-substring-no-properties (point-at-bol)
+                                           (point-at-eol)))))))
+
+(defun org-irc-erc-store-link ()
+  "Depending on the variable `org-irc-link-to-logs' store either
+a link to the log file for the current session or an irc: link to
+the session itself."
+  (if org-irc-link-to-logs
+      (let* ((erc-line (buffer-substring-no-properties
+                        (point-at-bol) (point-at-eol)))
+             (parsed-line (org-irc-erc-get-line-from-log erc-line)))
+        (if (erc-logging-enabled nil)
+            (progn
+              (org-store-link-props
+               :type "file"
+               :description (concat "'" (org-irc-elipsify-description
+                                         (cadr parsed-line) 20)
+                                    "' from an IRC conversation")
+               :link (concat "file:" (car parsed-line) "::"
+                             (cadr parsed-line)))
+              t)
+            (error "This ERC session is not being logged")))
+      (let* ((link-text (org-irc-get-erc-link))
+             (link (org-irc-parse-link link-text)))
+        (if link-text
+            (progn
+              (org-store-link-props
+               :type "irc"
+               :link (org-make-link "irc:/" link-text)
+               :description (concat "irc session '" link-text "'")
+               :server (car (car link))
+               :port (or (cadr (pop link)) erc-default-port)
+               :nick (pop link))
+              t)
+            (error "Failed to create ('irc:/' style) ERC link")))))
+
+(defun org-irc-get-erc-link ()
+  "Return an org compatible irc:/ link from an ERC buffer"
+  (let ((link (concat erc-server-announced-name ":"
+                      (number-to-string erc-session-port))))
+    (concat link "/"
+            (if (and (erc-default-target)
+                     (erc-channel-p (erc-default-target))
+                     (car (get-text-property (point) 'erc-data)))
+                ;; we can get a nick
+                (let ((nick (car (get-text-property (point) 'erc-data))))
+                  (concat (erc-default-target) "/" nick))
+                (erc-default-target)))))
+
+(defun org-irc-visit-erc (link)
+  "Visit an ERC buffer based on criteria from the followed link"
+  (let* ((server (car (car link)))
+         (port (or (cadr (pop link)) erc-default-port))
+         (server-buffer)
+         (buffer-list
+          (erc-buffer-filter
+           (lambda nil
+             (let ((tmp-server-buf (erc-server-buffer)))
+               (and tmp-server-buf
+                    (with-current-buffer tmp-server-buf
+                      (and
+                       (string= erc-session-port port)
+                       (string= erc-server-announced-name server)
+                       (setq server-buffer tmp-server-buf)))))))))
+    (if buffer-list
+        (let ((chan-name (pop link)))
+          ;; if we got a channel name then switch to it or join it
+          (if chan-name
+              (let ((chan-buf (find-if
+                               (lambda (x)
+                                 (string= (buffer-name x) chan-name))
+                               buffer-list)))
+                (if chan-buf
+                    (progn
+                      (switch-to-buffer chan-buf)
+                      ;; if we got a nick, and they're in the chan,
+                      ;; then start a chat with them
+                      (let ((nick (pop link)))
+                        (when nick
+                          (if (find nick (erc-get-server-nickname-list)
+                                    :test 'string=)
+                              (progn
+                                (goto-char (point-max))
+                                (insert (concat nick ": ")))
+                              (error "%s not found in %s" nick chan-name)))))
+                    (progn
+                      (switch-to-buffer server-buffer)
+                      (erc-cmd-JOIN chan-name))))
+              (switch-to-buffer server-buffer)))
+        ;; no server match, make new connection
+        (erc-select :server server :port port))))
+
+(provide 'org-irc)
+
+;;; 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 (file)
index 0000000..1e9fabc
--- /dev/null
@@ -0,0 +1,77 @@
+;;; org-mac-message.el - Support for links to Apple Mail messages by Message-ID
+;; Carstens outline-mode for keeping track of everything.
+;; Copyright (C) 2008 Free Software Foundation, Inc.
+;;
+;; Author: John Wiegey <johnw@gnu.org>
+;; Version: 1.2
+;; Keywords: outlines, hypermedia, calendar, wp
+;;
+;; This file is part of GNU Emacs.
+;;
+;; Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'org)
+
+(org-add-link-type "message" 'org-mac-message-open)
+
+(declare-function do-applescript "mac.c" (string))
+(unless (fboundp 'do-applescript)
+  ;; Need to fake this using shell-command-to-string
+  (defun do-applescript (script)
+    (let (start cmd return)
+      (while (string-match "\n" script)
+       (setq script (replace-match "\r" t t script)))
+      (while (string-match "'" script start)
+       (setq start (+ 2 (match-beginning 0))
+             script (replace-match "\\'" t t script)))
+      (setq cmd (concat "osascript -e '" script "'"))
+      (setq return (shell-command-to-string cmd))
+      (concat "\"" (org-trim return) "\""))))
+
+(defun org-mac-message-open (message-id)
+  "Visit the message with the given Message-ID.
+This will use the command `open' with the message url."
+  (start-process (concat "open message:" message-id) nil
+                "open" (concat "message://<" (substring message-id 2) ">")))
+
+(defun org-mac-message-insert-link ()
+  "Insert a link to the messages currently selected in Apple Mail.
+This will use applescript to get the message-id and the subject of the
+active mail in AppleMail and make a link out of it."
+  (interactive)
+  (insert (org-mac-message-get-link)))
+
+(defun org-mac-message-get-link ()
+  "Insert a link to the messages currently selected in Apple Mail.
+This will use applescript to get the message-id and the subject of the
+active mail in AppleMail and make a link out of it."
+  (let ((subject (do-applescript "tell application \"Mail\"
+       set theMessages to selection
+       subject of beginning of theMessages
+end tell"))
+       (message-id (do-applescript "tell application \"Mail\"
+       set theMessages to selection
+       message id of beginning of theMessages
+end tell")))
+    (org-make-link-string
+     (concat "message://"
+            (substring message-id 1 (1- (length message-id))))
+     (substring subject 1 (1- (length subject))))))
+
+(provide 'org-mac-message)
+
+;;; org-mac-message.el ends here