From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Re: patch: link to the log of an ERC session Date: Sun, 27 Jan 2008 18:53:32 +0000 Message-ID: <871w83cd77.fsf@bzg.ath.cx> References: <87k5mh4tn0.fsf@shellarchive.co.uk> <87d4s92msq.fsf@grepfind.mwolson.org> <87sl143adg.fsf@shellarchive.co.uk> <30FEEE51-7F9F-4CC6-A64B-F8B1814C3A9B@gmail.com> <87odblh9o6.fsf@shellarchive.co.uk> <87zluyq2g8.fsf@shellarchive.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJCdO-00081f-S7 for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 13:53:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJCdN-00080z-NE for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 13:53:37 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJCdN-00080v-9L for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 13:53:37 -0500 Received: from fk-out-0910.google.com ([209.85.128.189]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJCdM-00039P-Eq for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 13:53:37 -0500 Received: by fk-out-0910.google.com with SMTP id 26so914399fkx.10 for ; Sun, 27 Jan 2008 10:53:34 -0800 (PST) In-Reply-To: (Carsten Dominik's message of "Tue, 22 Jan 2008 14:19:56 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: org-mode mailing list --=-=-= Hi, Carsten Dominik 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 ! --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=org-link-irc.el.patch 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 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--