[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Re: patch: link to the log of an ERC session
From: |
Bastien |
Subject: |
Re: [Orgmode] Re: patch: link to the log of an ERC session |
Date: |
Sun, 27 Jan 2008 18:53:32 +0000 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.0 (gnu/linux) |
Hi,
Carsten Dominik <address@hidden> writes:
> I would really appreciate if people can test this out and give
> feedback - I would like to include this file with Org-mode, but I am
> not an irc/erc user myself.
I've been testing it and it works fine. The patch below does this:
- cosmetic re-indentation;
- minor (if COND (if COND ...) -> AND rewriting;
- when point is after ERC prompt, don't add this as a string for
contextual search, since such a search won't produce the right result.
Thanks for this add-on !
diff -u /home/guerry/org/ /home/guerry/org/Worg/org-code/org-link-irc.el
--- /home/guerry/org/org-link-irc.el 2008-01-27 18:47:50.000000000 +0000
+++ /home/guerry/org/Worg/org-code/org-link-irc.el 2008-01-27
18:38:11.000000000 +0000
@@ -46,6 +46,7 @@
(add-to-list 'org-store-link-functions
'org-link-irc-store-link)
+
(org-add-link-type "irc" 'org-link-irc-visit nil)
(defun org-link-irc-visit (link)
@@ -72,8 +73,8 @@
"Dispatch to the appropreate function to store a link to
something IRC related"
(cond
- ((eq major-mode 'erc-mode)
- (org-link-irc-erc-store-link))))
+ ((eq major-mode 'erc-mode)
+ (org-link-irc-erc-store-link))))
;; ERC specific functions
@@ -94,44 +95,43 @@
;; a simple file link does here (use regexp?)
(setq cpltxt (concat "file:" (abbreviate-file-name
buffer-file-name)
- "::" erc-line))
+ (unless (equal erc-line (erc-prompt))
+ (concat "::" erc-line))))
(org-make-link cpltxt)
-
t))
- (error "This ERC session is not being logged")))
- (let ((link (org-link-irc-get-erc-link)))
- (if link
- (progn
- (setq cpltxt (concat "irc:/" link))
- (org-make-link cpltxt)
- (setq link (org-link-irc-parse-link link))
- (org-store-link-props :type "irc" ; for remember
- :server (car (car link))
- :port (or (cadr (pop link))
- erc-default-port)
- :nick (pop link))
- t)
- (error "Failed to create (non-log) ERC link")))))
+ (error "This ERC session is not being logged")))
+ (let ((link (org-link-irc-get-erc-link)))
+ (if link
+ (progn
+ (setq cpltxt (concat "irc:/" link))
+ (org-make-link cpltxt)
+ (setq link (org-link-irc-parse-link link))
+ (org-store-link-props :type "irc" ; for remember
+ :server (car (car link))
+ :port (or (cadr (pop link))
+ erc-default-port)
+ :nick (pop link))
+ t)
+ (error "Failed to create (non-log) ERC link")))))
(defun org-link-irc-get-erc-link ()
"Return an org compatible irc:/ link from an ERC buffer"
(let ((link (concat erc-server-announced-name ":"
erc-session-port)))
(concat link "/"
- (if (erc-default-target)
- (if (erc-channel-p (erc-default-target))
- (if (and (get-text-property (point) 'erc-parsed)
- (elt (get-text-property (point) 'erc-parsed) 1))
- ;; we can get a nick
- (let ((nick
- (car
- (erc-parse-user
- (elt (get-text-property (point)
- 'erc-parsed) 1)))))
- (concat (erc-default-target) "/"
- (substring nick 1)))
- (erc-default-target))
- (erc-default-target))))))
+ (if (and (erc-default-target)
+ (erc-channel-p (erc-default-target))
+ (get-text-property (point) 'erc-parsed)
+ (elt (get-text-property (point) 'erc-parsed) 1))
+ ;; we can get a nick
+ (let ((nick
+ (car
+ (erc-parse-user
+ (elt (get-text-property (point)
+ 'erc-parsed) 1)))))
+ (concat (erc-default-target) "/"
+ (substring nick 1)))
+ (erc-default-target)))))
(defun org-link-irc-visit-erc (link)
"Visit an ERC buffer based on criteria from the followed link"
@@ -142,12 +142,12 @@
(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)))))))))
+ (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
@@ -168,13 +168,13 @@
(progn
(goto-char (point-max))
(insert (concat nick ": ")))
- (error "%s not found in %s" nick chan)))))
- (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))))
+ (error "%s not found in %s" nick chan)))))
+ (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-link-irc)
Diff finished. Sun Jan 27 18:48:02 2008
--
Bastien
- [Orgmode] patch: link to the log of an ERC session, Phil Jackson, 2008/01/10
- [Orgmode] Re: patch: link to the log of an ERC session, Michael Olson, 2008/01/10
- Re: [Orgmode] Re: patch: link to the log of an ERC session, Phil Jackson, 2008/01/11
- Re: [Orgmode] Re: patch: link to the log of an ERC session, Carsten Dominik, 2008/01/16
- Re: [Orgmode] Re: patch: link to the log of an ERC session, Phil Jackson, 2008/01/16
- Re: [Orgmode] Re: patch: link to the log of an ERC session, Phil Jackson, 2008/01/21
- Re: [Orgmode] Re: patch: link to the log of an ERC session, Carsten Dominik, 2008/01/22
- Re: [Orgmode] Re: patch: link to the log of an ERC session,
Bastien <=
- Re: [Orgmode] Re: patch: link to the log of an ERC session, Phil Jackson, 2008/01/28