annotate lisp/org/org-irc.el @ 96044:c1ef445563bb

2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-colview.el (org-columns-next-allowed-value): Bug fix. * org-colview-xemacs.el (org-columns-next-allowed-value): Bug fix. * org-agenda.el (org-agenda-get-closed): Get the end time into the agenda prefix as well. * org-publish.el (org-publish-org-index): Make a properly indented list. * org.el (org-calendar-agenda-action-key): New option. (org-get-cursor-date): New function. (org-mark-entry-for-agenda-action): New command. (org-overriding-default-time): New variable. (org-read-date): Respect `org-overriding-default-time'. * org-remember.el (org-remember-apply-template): Respect the ovverriding default time. * org-agenda.el (org-agenda-action-marker): New variable. (org-agenda-action): New command. (org-agenda-do-action): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-schedule, org-deadline): Protect scheduled and deadline tasks against changes that accidently remove the repeater. Also show a message with the new date when done. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-beginning-of-line): Cater for the case when there are tags but no headline text. (org-align-tags-here): Convert to tabs only when indent-tabs-mode it set. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-mhe.el (org-mhe-get-message-folder-from-index): Make sure the return value is nil instead of "nil" when there is no match. * org-exp.el (org-insert-centered): Use fill-column instead of 80. (org-export-as-ascii): Use string-width to measure the width of the heading. * org.el (org-diary-to-ical-string): No longer kill buffer FROMBUF, this is now done by the caller. * org-exp.el (org-print-icalendar-entries): Move the call to `org-diary-to-ical-string' out of the loop, and kill the buffer afterwords. * org-remember.el (org-remember-visit-immediately): Position cursor after moving to the note. (org-remember-apply-template): Use a text property to record the cursor position. (org-remember-handler): Align tags after pasting the note. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-bbdb.el (org-bbdb-follow-anniversary-link): New function. * org-agenda.el (org-agenda-open-link): If there is an org-bbdb-name property in the current line, jump to that bbdb entry. * org-bbdb.el (org-bbdb-anniversaries): Add the bbdb-name as a text property, so that the agenda knows where this entry comes from. * org-agenda.el (org-agenda-clock-in): Fixed bug in the interaction between clocking-in from the agenda, and automatic task state switching. * org-macs.el (org-with-point-at): Bug fix in macro defintion. * org.el (org-beginning-of-line, org-end-of-line): Make sure the zmacs-region stays after this command in XEmacs. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-scan-tags): Allow new values for ACTION parameter. * org-remember.el (org-remember-templates): Fix bug in customization type definition. * org.el (org-map-entries): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-skip-comment-trees): New option. (org-agenda-skip): Respect `org-agenda-skip-comment-trees'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-remember.el (org-jump-to-target-location): New variable. (org-remember-apply-template): Set `org-remember-apply-template' if requested by template. (org-remember-handler): Start an idle timer to jump to remember location. * org-exp.el (org-get-current-options): Add the FILETAGS setting. * org.el (org-set-regexps-and-options): Fix bug with parsing of file tags. (org-get-tags-at): Add the content of `org-file-tags'. * org-exp.el (org-export-handle-comments): Fix bug with several comment lines after each other. (org-number-to-roman, org-number-to-counter): New functions. (org-export-section-number-format): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-protect-examples): Catch the case of a missing end_example line. * org.el (org-set-regexps-and-options): Set `org-file-properties' and `org-file-tags' to nil. * org-colview.el (org-columns-next-allowed-value): Handle next argument NTH to directly select a value. * org-colview-xemacs.el (org-columns-next-allowed-value): Handle next argument NTH to directly select a value. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-scheduled-leaders): Fix docstring. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-columns-ellipses): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-colview.el (org-columns-add-ellipses): New function. (org-columns-compact-links): New function. (org-columns-cleanup-item): Call `org-columns-compact-links'. (org-columns-display-here): Call `org-agenda-columns-cleanup-item' when in agenda. (org-columns-edit-value): Fixed bug with editing values from agenda column view. (org-columns-redo): Also redo the agenda itself. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-columns-remove-prefix-from-item): New option. * org-colview.el (org-agenda-columns-cleanup-item): New function. * org-exp.el (org-export-ascii-preprocess): Renamed from `org-export-ascii-clean-string'. (org-export-kill-licensed-text) (org-export-define-heading-targets) (org-export-handle-invisible-targets) (org-export-target-internal-links) (org-export-remove-or-extract-drawers) (org-export-remove-archived-trees) (org-export-protect-quoted-subtrees) (org-export-protect-verbatim, org-export-protect-examples) (org-export-select-backend-specific-text) (org-export-mark-blockquote-and-verse) (org-export-remove-comment-blocks-and-subtrees) (org-export-handle-comments, org-export-mark-radio-links) (org-export-remove-special-table-lines) (org-export-normalize-links) (org-export-concatenate-multiline-links) (org-export-concatenate-multiline-emphasis): New functions, obtained from spliiting the export preprocessor. * org-table.el (org-table-recalculate): Improve error message if the row number is invalid. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-archive.el (org-archive-save-context-info): Fix bugs in customization setup and docstring. * org-exp.el (org-export-html-style): Changed the size of in the <pre> element to 90%. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-find-src-example-start): Function removed. (org-edit-src-find-region-and-lang): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-edit-src-exit): New function. (org-exit-edit-mode): New minor mode. * org-exp.el (org-export-preprocess-string): Fix bug with removing comment-like lines from protected examples. * org.el (org-edit-src-example, org-find-src-example-start) (org-protect-source-example, org-edit-special): New functions. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-publish.el (org-publish-project-alist): Fix typo in docstring. (org-publish-project-alist): Handle :index-title property. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-export-latex.el (org-export-as-latex): Make sure region bounds are correct. Parse subtree properties relating to export. * org-exp.el (org-export-add-options-to-plist): New function. (org-infile-export-plist): Use `org-export-add-options-to-plist'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-default-properties): Add EXPORT_FILE_NAME and EXPORT_TITLE. * org-exp.el (org-export-get-title-from-subtree) (org-export-as-ascii, org-export-as-html): Make sure the original region-beginning and region-end are used, even after moving point. (org-export-get-title-from-subtree): Also try the EXPORT_TITLE property. * org-remember.el (org-remember-last-stored-marker): New variable. (org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'. (org-remember-handler): Also use marker to remember last-stored position. * org.el (org-goto-marker-or-bmk): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-file-properties): Renamed from `org-local-properties'. (org-scan-tags): Take file tags into account. (org-tags-match-list-sublevels): Default changed to t. * org-exp.el (org-export-as-html): Close paragraph after a footnote. * org.el (org-update-parent-todo-statistics): New function. * org-exp.el (org-icalendar-store-UID): New option. (org-icalendar-force-UID): Option removed. (org-print-icalendar-entries): IMplement UIDs. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-mhe.el (org-mhe-follow-link): Fix bug in mhe searches. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-faces.el (org-column): Document how this face is being used and why sometimes the background faces shine through. * org-mhe.el (org-mhe-follow-link): Improve handling of searches. * org-publish.el (org-publish-attachment): Create publishing directory if it does not yet exist. * org-table.el (org-calc-default-modes): Change default number format to (float 8). * org.el (org-olpath-completing-read): New function. (org-time-clocksum-format): New option. (org-minutes-to-hh:mm-string): Use `org-time-clocksum-format'. * org-clock.el (org-clock-display, org-clock-out) (org-update-mode-line): Use `org-time-clocksum-format'. * org-colview-xemacs.el (org-columns-number-to-string): Use `org-time-clocksum-format'. * org-colview.el (org-columns-number-to-string): Use `org-time-clocksum-format'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-id.el: New file, move from contrib to core. * org-exp.el (org-icalendar-force-UID): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-print-icalendar-entries): Make sure DTEND is shifted by one day if theere is a date range without an end time. * org.el (org-try-structure-completion): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-font-lock-defaults): Improve fontification of description lists. (org-insert-item): Handle description lists. (org-adaptive-fill-function): Improve auto indentation in description lists. * org-exp.el (org-export-as-html, org-export-preprocess-string): Implement VERSE environment. (org-export-preprocess-string): Implement the COMMENT environment. * org-export-latex.el (org-export-latex-preprocess): Implement VERSE environment. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-jsinfo.el (org-infojs-opts-table): Add entry for FIXED_TOC option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-table.el (orgtbl-to-tsv, orgtbl-to-csv): New functions. * org.el (org-quote-csv-field): New functions. * org-table.el (org-table-export-default-format): Remove :splice from default format, we get the same effect by not specifying :tstart and :tend. (org-table-export): Improve setup, distinguish better between interactive and non-interactive use, allow specifying the format on the fly, better protection against wrong file names. (orgtbl-to-generic): Fix documentation. Do not require :tstart and :tend when :splice is omitted. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-select-task): Make sure the selection letters are 1-9 and A-Z, no special characters. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-htmlize): New group. (org-export-htmlize-output-type) (org-export-htmlize-css-font-prefix): New options. (org-export-htmlize-region-for-paste): New function. (org-export-htmlize-generate-css): New command. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-visibility-according-to-property): New function. (org-ctrl-c-ctrl-c): Do not restart org-mode, just get the options and compute the regular expressions, and update font-lock. (org-property-re): Allow a dash in property names. * org-archive.el (org-extract-archive-file): Insert the file name without the path into the format, to allow the location format to contain a subdirectory. * org-agenda.el (org-agenda-post-command-hook): If point is at end of buffer, and the `org-agenda-type' property undefined, use the value from the character before. * org.el (org-add-planning-info): Don't let indentation for would-be timestamp become extra whitespace at the end of headline. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-remove-double-quotes, org-file-contents): New functions. * org-exp.el (org-infile-export-plist): Also parse the contents of #+SETUPFILE files, recursively. * org.el (org-set-regexps-and-options): Also parse the contents of #+SETUPFILE files, recursively. * org-exp.el (org-export-handle-include-files): New function. (org-export-preprocess-string): Call `org-export-handle-include-files'. * org.el (org-delete-property-globally) (org-delete-property, org-set-property): Ignore case during completion. (org-set-property): Use `org-completing-read' instead of `completing-read'. * org.el (org-complete-expand-structure-template): New, experimental function. (org-structure-template-alist): New, experimental option. (org-complete): Call `org-complete-expand-structure-template'. 2008-06-17 Bastien Guerry <bzg@altern.org> * org-export-latex.el (org-export-latex-preprocess): Added support for blockquotes. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-read-date-analyze): Catch the case where only a weekday is given. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-font-lock-defaults): Make the description tag bold. * org-exp.el (org-export-as-html, org-close-li): Implement description lists. 2008-06-17 Jason Riedy <jason@acm.org> * org-table.el (*orgtbl-default-fmt*): New variable. (orgtbl-format-line): Use the value of *orgtbl-default-fmt* when there is no other fmt available. (orgtbl-to-generic): Allow an explicitly nil :tstart or :tend to suppress the appropriate string. (orgtbl-to-orgtbl): New function for translating to another orgtbl table. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-read-date-analyze): "." as an alias for "+0" in read date. * org-clock.el (org-clock-save-markers-for-cut-and-paste): New function. * org-agenda.el (org-agenda-save-markers-for-cut-and-paste): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-find-position): Don't include notes into clock drawer. * org-archive.el (org-archive-subtree): No longer remove an extra line after cutting the subtree. `org-cut-subtree' already takes care of this. * org-remember.el (org-remember-handler): Only kill the target buffer if it does not contain the running clock. * org.el (org-markers-to-move): New variable. (org-save-markers-in-region, org-check-and-save-marker) (org-reinstall-markers-in-region): New function. (org-move-subtree-down, org-copy-subtree): Remember relative marker positions before cutting. (org-move-subtree-down, org-paste-subtree): Restore relative marker positions after pasting. * org-remember.el (org-remember-clock-out-on-exit): New option. (org-remember-finalize): Clock out only if the setting in `org-remember-clock-out-on-exit' requires it. (org-remember-handler): Do the cleanup in the buffer, to make sure that the clock marker remains in tact. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-goto): Widen buffer if necessary. (org-clock-in): Make sure that also tasks outside the narrowed region will be clocked in correctly. (org-clock-insert-selection-line): Widen the buffer so that we can find the correct task heading. * org.el (org-base-buffer): New function. * org-exp.el (org-icalendar-cleanup-string): Make sure '," and ";" are escaped. (org-print-icalendar-entries): Also apply `org-icalendar-cleanup-string' to the headline, not only to the summary property. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-preprocess-hook): New hook. (org-export-preprocess-string): Call `org-export-preprocess-hook'. * org.el (org-font-lock-hook): New variable. (org-font-lock-hook): New function. (org-set-font-lock-defaults): Call `org-font-lock-hook'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.texi: Modify license to no longer include back- and front cover matters. (Using the mapping API): New section. (Agenda column view): New section. (Moving subtrees): Document archiving to the archive sibling. (Agenda commands): Document columns view in the agenda. (Using the property API): Document the API for multi-valued properties.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 17 Jun 2008 15:22:00 +0000
parents 8634b4393320
children 60149c696033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-irc.el --- Store links to IRC sessions
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
2 ;;
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3 ;; Copyright (C) 2008 Free Software Foundation, Inc.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
4 ;;
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Keywords: erc, irc, link, org
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94767
diff changeset
7 ;; Version: 6.05a
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
8 ;;
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
10 ;;
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
14 ;; (at your option) any later version.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; GNU General Public License for more details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;;; Commentary:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
26 ;; This file implements links to an IRC session from within Org-mode.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
27 ;; Org-mode loads this module by default - if this is not what you want,
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
28 ;; configure the variable `org-modules'.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;;
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
30 ;; Please customize the variable `org-default-extensions' to select
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
31 ;; extensions you would like to use, and to deselect those which you don't
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
32 ;; want.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;;
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
34 ;; Please note that at the moment only ERC is supported. Other clients
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
35 ;; shouldn't be difficult to add though.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 ;; Then set `org-irc-link-to-logs' to non-nil if you would like a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; file:/ type link to be created to the current line in the logs or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;; to t if you would like to create an irc:/ style link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;; Links within an org buffer might look like this:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;; [[irc:/irc.freenode.net/#emacs/bob][chat with bob in #emacs on freenode]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; [[irc:/irc.freenode.net/#emacs][#emacs on freenode]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 ;; [[irc:/irc.freenode.net/]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;; If, when the resulting link is visited, there is no connection to a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; requested server then one will be created.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 ;;; Code:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 (require 'org)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
53
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
54 ;; Declare the function fomr ERC that we use.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
55 (declare-function erc-current-logfile "erc-log" (&optional buffer))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
56 (declare-function erc-prompt "erc" ())
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
57 (declare-function erc-default-target "erc" ())
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
58 (declare-function erc-channel-p "erc" (channel))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
59 (declare-function erc-buffer-filter "erc" (predicate &optional proc))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
60 (declare-function erc-server-buffer "erc" ())
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
61 (declare-function erc-get-server-nickname-list "erc" ())
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
62 (declare-function erc-cmd-JOIN "erc" (channel &optional key))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 (defvar org-irc-client 'erc
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
65 "The IRC client to act on.")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 (defvar org-irc-link-to-logs nil
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
67 "Non-nil will store a link to the logs, nil will store an irc: style link.")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
69 (defvar erc-default-port) ; dynamically scoped from erc.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
70 (defvar erc-session-port) ; dynamically scoped form erc-backend.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
71 (defvar erc-session-server) ; dynamically scoped form erc-backend.el
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 ;; Generic functions/config (extend these for other clients)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
75 (add-to-list 'org-store-link-functions 'org-irc-store-link)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 (org-add-link-type "irc" 'org-irc-visit nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 (defun org-irc-visit (link)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
80 "Parse LINK and dispatch to the correct function based on the client found."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 (let ((link (org-irc-parse-link link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 ((eq org-irc-client 'erc)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 (org-irc-visit-erc link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 (error "erc only known client")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 (defun org-irc-parse-link (link)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
89 "Parse an IRC LINK and return the attributes found.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
90 Parse a LINK that looks like server:port/chan/user (port, chan
94767
8634b4393320 (org-irc-parse-link): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
91 and user being optional) and return any of the port, channel or user
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
92 attributes that are found."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 (let* ((parts (split-string link "/" t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 (len (length parts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 (when (or (< len 1) (> len 3))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
96 (error "Failed to parse link needed 1-3 parts, got %d" len))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 (setcar parts (split-string (car parts) ":" t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 parts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 (defun org-irc-store-link ()
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
102 "Dispatch to the appropriate function to store a link to an IRC session."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 ((eq major-mode 'erc-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 (org-irc-erc-store-link))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 (defun org-irc-elipsify-description (string &optional after)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
108 "Remove unnecessary white space from STRING and add ellipses if necessary.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
109 Strip starting and ending white space from STRING and replace any
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
110 chars that the value AFTER with '...'"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 (let* ((after (number-to-string (or after 30)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 (replace-map (list (cons "^[ \t]*" "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 (cons "[ \t]*$" "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 (cons (concat "^\\(.\\{" after
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 "\\}\\).*") "\\1..."))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 (mapc (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 (when (string-match (car x) string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 (setq string (replace-match (cdr x) nil nil string))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 replace-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 ;; ERC specific functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 (defun org-irc-erc-get-line-from-log (erc-line)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
125 "Find the best line to link to from the ERC logs given ERC-LINE as a start.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
126 If the user is on the ERC-prompt then search backward for the
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
127 first non-blank line, otherwise return the current line. The
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
128 result is a cons of the filename and search string."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 (erc-save-buffer-in-logs)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
130 (require 'erc-log)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 (with-current-buffer (find-file-noselect (erc-current-logfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 (abbreviate-file-name buffer-file-name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 ;; can we get a '::' part?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 (if (string= erc-line (erc-prompt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 (when (search-backward-regexp "^[^ ]" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 (buffer-substring-no-properties (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 (point-at-eol))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (when (search-backward erc-line nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 (buffer-substring-no-properties (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (point-at-eol)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 (defun org-irc-erc-store-link ()
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
147 "Store a link to the IRC log file or the session itself.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
148 Depending on the variable `org-irc-link-to-logs' store either a
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
149 link to the log file for the current session or an irc: link to
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 the session itself."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
151 (require 'erc-log)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 (if org-irc-link-to-logs
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 (let* ((erc-line (buffer-substring-no-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 (point-at-bol) (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (parsed-line (org-irc-erc-get-line-from-log erc-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 (if (erc-logging-enabled nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 (org-store-link-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 :type "file"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 :description (concat "'" (org-irc-elipsify-description
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 (cadr parsed-line) 20)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 "' from an IRC conversation")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 :link (concat "file:" (car parsed-line) "::"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 (cadr parsed-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 (error "This ERC session is not being logged")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 (let* ((link-text (org-irc-get-erc-link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (link (org-irc-parse-link link-text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 (if link-text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 (org-store-link-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172 :type "irc"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 :link (org-make-link "irc:/" link-text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 :description (concat "irc session '" link-text "'")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 :server (car (car link))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
176 :port (or (string-to-number (cadr (pop link))) erc-default-port)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 :nick (pop link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 (error "Failed to create ('irc:/' style) ERC link")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 (defun org-irc-get-erc-link ()
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
182 "Return an org compatible irc:/ link from an ERC buffer."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
183 (let* ((session-port (if (numberp erc-session-port)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
184 (number-to-string erc-session-port)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
185 erc-session-port))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
186 (link (concat erc-session-server ":" session-port)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 (concat link "/"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 (if (and (erc-default-target)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 (erc-channel-p (erc-default-target))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (car (get-text-property (point) 'erc-data)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 ;; we can get a nick
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (let ((nick (car (get-text-property (point) 'erc-data))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 (concat (erc-default-target) "/" nick))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (erc-default-target)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
196 (defun org-irc-get-current-erc-port ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
197 "Return the current port as a number.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
198 Return the current port number or, if none is set, return the ERC
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
199 default."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
200 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
201 ((stringp erc-session-port)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
202 (string-to-number erc-session-port))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
203 ((numberp erc-session-port)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
204 erc-session-port)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
205 (t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
206 erc-default-port)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
207
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 (defun org-irc-visit-erc (link)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
209 "Visit an ERC buffer based on criteria found in LINK."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
210 (require 'erc)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
211 (require 'erc-log)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 (let* ((server (car (car link)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
213 (port (or (string-to-number (cadr (pop link))) erc-default-port))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 (server-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 (buffer-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (erc-buffer-filter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 (let ((tmp-server-buf (erc-server-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 (and tmp-server-buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 (with-current-buffer tmp-server-buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 (and
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
222 (eq (org-irc-get-current-erc-port) port)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93141
diff changeset
223 (string= erc-session-server server)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 (setq server-buffer tmp-server-buf)))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 (if buffer-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 (let ((chan-name (pop link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227 ;; if we got a channel name then switch to it or join it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 (if chan-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 (let ((chan-buf (catch 'found
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 (dolist (x buffer-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 (if (string= (buffer-name x) chan-name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 (throw 'found x))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 (if chan-buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 (switch-to-buffer chan-buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236 ;; if we got a nick, and they're in the chan,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 ;; then start a chat with them
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 (let ((nick (pop link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 (when nick
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 (if (member nick (erc-get-server-nickname-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 (insert (concat nick ": ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 (error "%s not found in %s" nick chan-name)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 (switch-to-buffer server-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 (erc-cmd-JOIN chan-name))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 (switch-to-buffer server-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249 ;; no server match, make new connection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 (erc-select :server server :port port))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 (provide 'org-irc)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 ;; arch-tag: 018d7dda-53b8-4a35-ba92-6670939e525a
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94767
diff changeset
255
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 ;;; org-irc.el ends here