emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* patch: link to the log of an ERC session
@ 2008-01-10 14:55 Phil Jackson
  2008-01-11  1:06 ` Michael Olson
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Jackson @ 2008-01-10 14:55 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

I get a lot of my information from ERC/bitlbee so wrote this patch to
allow for linking against the log associated with an ERC session.

Sorry, only tested in GNU.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-erc-links.diff --]
[-- Type: text/x-diff, Size: 1161 bytes --]

--- /home/phil/org-5.18a/org.el	2008-01-06 15:30:26.000000000 +0000
+++ org.el	2008-01-10 14:12:27.000000000 +0000
@@ -11765,6 +11765,22 @@
 	      link (org-make-link cpltxt))
 	(org-store-link-props :type "bbdb" :name name :company company)))
 
+     ((eq major-mode 'erc-mode)
+      (let ((erc-line (buffer-substring-no-properties
+                       (point-at-bol) (point-at-eol))))
+        (if (erc-logging-enabled nil)
+            (progn
+              (erc-save-buffer-in-logs)
+              (with-current-buffer (find-file-noselect (erc-current-logfile))
+                (goto-char (point-max))
+                (unless (search-backward erc-line nil t)
+                  (error "Unable to find this line in the logs: '%s'"
+                         erc-line))
+                  (setq cpltxt (concat "file:" (abbreviate-file-name
+                                                buffer-file-name)
+                                       "::" erc-line))))
+            (error "This ERC session is not being logged"))))
+
      ((eq major-mode 'Info-mode)
       (setq link (org-make-link "info:"
 				(file-name-nondirectory Info-current-file)

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


Cheers,
Phil

[-- 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch: link to the log of an ERC session
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Olson @ 2008-01-11  1:06 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 742 bytes --]

Phil Jackson <phil@shellarchive.co.uk> writes:

> Hi,
>
> I get a lot of my information from ERC/bitlbee so wrote this patch to
> allow for linking against the log associated with an ERC session.

It's interesting that you're linking to the log file.  I hadn't thought
of doing that before, but I like the idea.  Planner's ERC integration
causes a new conversation to that person to be launched when clicking on
its generated link.  I could see merits in each approach.

-- 
       Michael Olson -- FSF Associate Member #652     |
 http://mwolson.org/ -- Jabber: mwolson_at_hcoop.net  |  /` |\ | | |
          Programmer -- Hobbies: Lisp, HCoop          | |_] | \| |_|
Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-11  1:06 ` Michael Olson
@ 2008-01-11 10:49   ` Phil Jackson
  2008-01-16 16:52     ` Carsten Dominik
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Jackson @ 2008-01-11 10:49 UTC (permalink / raw)
  To: Michael Olson; +Cc: emacs-orgmode

Michael Olson <mwolson@gnu.org> writes:

>> I get a lot of my information from ERC/bitlbee so wrote this patch to
>> allow for linking against the log associated with an ERC session.
>
> It's interesting that you're linking to the log file.  I hadn't
> thought of doing that before, but I like the idea.  Planner's ERC
> integration causes a new conversation to that person to be launched
> when clicking on its generated link.  I could see merits in each
> approach.

As I just make a 'file://' link to the log there is no reason org
couldn't have an 'irc://' link too. Might be a little confusing for
users having two places in the same buffer where C-c l could collect
different links though :/

Cheers,
Phil

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-11 10:49   ` Phil Jackson
@ 2008-01-16 16:52     ` Carsten Dominik
  2008-01-16 19:06       ` Phil Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2008-01-16 16:52 UTC (permalink / raw)
  To: Phil Jackson; +Cc: emacs-orgmode, Michael Olson


On Jan 11, 2008, at 11:49 AM, Phil Jackson wrote:

> Michael Olson <mwolson@gnu.org> writes:
>
>>> I get a lot of my information from ERC/bitlbee so wrote this patch  
>>> to
>>> allow for linking against the log associated with an ERC session.
>>
>> It's interesting that you're linking to the log file.  I hadn't
>> thought of doing that before, but I like the idea.  Planner's ERC
>> integration causes a new conversation to that person to be launched
>> when clicking on its generated link.  I could see merits in each
>> approach.
>
> As I just make a 'file://' link to the log there is no reason org
> couldn't have an 'irc://' link too. Might be a little confusing for
> users having two places in the same buffer where C-c l could collect
> different links though :/

How about writing a little extension org-irc.el that extends the link
mechanism for both cases? I'd love to see more such extensions, and I
would be happy to distribute them with Org-mode, and to put them into
Emacs if the papers are in order.

In fact, I am thinking about putting more of the link stuff into
separate files, if I can find the time.

- Carsten

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-16 16:52     ` Carsten Dominik
@ 2008-01-16 19:06       ` Phil Jackson
  2008-01-21 21:43         ` Phil Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Jackson @ 2008-01-16 19:06 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Michael Olson

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On Jan 11, 2008, at 11:49 AM, Phil Jackson wrote:
>
>> Michael Olson <mwolson@gnu.org> writes:
>>
>>>> I get a lot of my information from ERC/bitlbee so wrote this patch
>>>> to allow for linking against the log associated with an ERC
>>>> session.
>>>
>>> It's interesting that you're linking to the log file.  I hadn't
>>> thought of doing that before, but I like the idea.  Planner's ERC
>>> integration causes a new conversation to that person to be launched
>>> when clicking on its generated link.  I could see merits in each
>>> approach.
>>
>> As I just make a 'file://' link to the log there is no reason org
>> couldn't have an 'irc://' link too. Might be a little confusing for
>> users having two places in the same buffer where C-c l could collect
>> different links though :/
>
> How about writing a little extension org-irc.el that extends the link
> mechanism for both cases? I'd love to see more such extensions, and I
> would be happy to distribute them with Org-mode, and to put them into
> Emacs if the papers are in order.

Sure, I'll get a patch to you when I can.

Cheers,
Phil
-- 
 Phil Jackson
 http://www.shellarchive.co.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-16 19:06       ` Phil Jackson
@ 2008-01-21 21:43         ` Phil Jackson
  2008-01-22 13:19           ` Carsten Dominik
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Jackson @ 2008-01-21 21:43 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Michael Olson, emacs-orgmode

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

Phil Jackson <phil@shellarchive.co.uk> writes:

[...]

>> How about writing a little extension org-irc.el that extends the link
>> mechanism for both cases? I'd love to see more such extensions, and I
>> would be happy to distribute them with Org-mode, and to put them into
>> Emacs if the papers are in order.
>
> Sure, I'll get a patch to you when I can.

Please find attached a 'beta' of the plugin. If anyone could give it a
quick test that would be great. It needs a little bit of re-factoring I
think so I'll do that post critique.


[-- Attachment #2: org-link-irc.el --]
[-- Type: application/emacs-lisp, Size: 7401 bytes --]

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


Phil
-- 
 Phil Jackson
 http://www.shellarchive.co.uk

[-- 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-21 21:43         ` Phil Jackson
@ 2008-01-22 13:19           ` Carsten Dominik
  2008-01-27 18:53             ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2008-01-22 13:19 UTC (permalink / raw)
  To: Phil Jackson; +Cc: org-mode mailing list


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.

Thanks

- Carsten

On Jan 21, 2008, at 10:43 PM, Phil Jackson wrote:

> Phil Jackson <phil@shellarchive.co.uk> writes:
>
> [...]
>
>>> How about writing a little extension org-irc.el that extends the  
>>> link
>>> mechanism for both cases? I'd love to see more such extensions,  
>>> and I
>>> would be happy to distribute them with Org-mode, and to put them  
>>> into
>>> Emacs if the papers are in order.
>>
>> Sure, I'll get a patch to you when I can.
>
> Please find attached a 'beta' of the plugin. If anyone could give it a
> quick test that would be great. It needs a little bit of re- 
> factoring I
> think so I'll do that post critique.
>
> <org-link-irc.el>
> Phil
> -- 
> Phil Jackson
> http://www.shellarchive.co.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-22 13:19           ` Carsten Dominik
@ 2008-01-27 18:53             ` Bastien
  2008-01-28 17:43               ` Phil Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2008-01-27 18:53 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode mailing list

[-- 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: patch: link to the log of an ERC session
  2008-01-27 18:53             ` Bastien
@ 2008-01-28 17:43               ` Phil Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Phil Jackson @ 2008-01-28 17:43 UTC (permalink / raw)
  To: Bastien; +Cc: org-mode mailing list, Carsten Dominik

Chaps,

Bastien <bzg@altern.org> writes:

> 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:

[...]

> - 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.

I'm not sure that will produce the right result either in that
case. What about if I changed it to link to the line above (if there
isn't one then just the file)?

> Thanks for this add-on

No problemo :)

[...]

Cheers,
Phil
-- 
 Phil Jackson
 http://www.shellarchive.co.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-01-28 17:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2008-01-28 17:43               ` Phil Jackson

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).