emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Re: patch: link to the log of an ERC session
Date: Sun, 27 Jan 2008 18:53:32 +0000	[thread overview]
Message-ID: <871w83cd77.fsf@bzg.ath.cx> (raw)
In-Reply-To: <B469E56F-1CBE-4BE9-9BC2-03B100B653B7@gmail.com> (Carsten Dominik's message of "Tue, 22 Jan 2008 14:19:56 +0100")

[-- Attachment #1: Type: text/plain, Size: 537 bytes --]

Hi,

Carsten Dominik <carsten.dominik@gmail.com> 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 !


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-link-irc.el.patch --]
[-- Type: text/x-diff, Size: 5532 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


-- 
Bastien

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

  reply	other threads:[~2008-01-27 18:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-10 14:55 patch: link to the log of an ERC session Phil Jackson
2008-01-11  1:06 ` Michael Olson
2008-01-11 10:49   ` Phil Jackson
2008-01-16 16:52     ` Carsten Dominik
2008-01-16 19:06       ` Phil Jackson
2008-01-21 21:43         ` Phil Jackson
2008-01-22 13:19           ` Carsten Dominik
2008-01-27 18:53             ` Bastien [this message]
2008-01-28 17:43               ` Phil Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871w83cd77.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).