emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-protocol and missing server-delete-client function
@ 2009-04-16 20:29 John Rakestraw
  2009-04-16 21:09 ` Sebastian Rose
  2009-04-16 23:22 ` Sebastian Rose
  0 siblings, 2 replies; 4+ messages in thread
From: John Rakestraw @ 2009-04-16 20:29 UTC (permalink / raw)
  To: emacs-orgmode

Hi --

I'm a simple guy, not a coder, and only a little emacs-savvy. However,
this post might save some people some frustration. (And it might prompt
someone more emacs-savvy than I to teach me something.)

I faced a challenge getting org-protocol to work.

I'm running the latest org-mode from git on a Fedora 10 box. Emacs
version 22.3.1. I set up for org-protocol in emacs and in firefox
(following the instructions at
http://orgmode.org/worg/org-contrib/org-protocol.php). Then when I
tried to execute the org-protocol-remember handler, emacs pitched back
this error message:

***
error in process filter: symbol's function definition is void:
server-delete-client
***

I looked in server.el, and didn't find server-delete-client defined
there. I found a copy of server.el for emacs 23 online at
http://zchan.homeunix.net/pub/Nevada.APP/Build/emacs-23.0.60/lisp/server.el/server.
It includes this definition of server-delete-client:

***
(defun server-delete-client (proc &optional noframe)
  "Delete CLIENT, including its buffers, terminals and frames.
If NOFRAME is non-nil, let the frames live.  (To be used from
`delete-frame-functions'.)"
  (server-log (concat "server-delete-client" (if noframe " noframe"))
	      proc)
  ;; Force a new lookup of client (prevents infinite recursion).
  (when (memq proc server-clients)
    (let ((buffers (process-get proc 'buffers)))

      ;; Kill the client's buffers.
      (dolist (buf buffers)
	(when (buffer-live-p buf)
	  (with-current-buffer buf
	    ;; Kill the buffer if necessary.
	    (when (and (equal server-buffer-clients
			      (list proc))
		       (or (and server-kill-new-buffers
				(not server-existing-buffer))
			   (server-temp-file-p))
		       (not (buffer-modified-p)))
	      (let (flag)
		(unwind-protect
		    (progn (setq server-buffer-clients nil)
			   (kill-buffer (current-buffer))
			   (setq flag t))
		  (unless flag
		    ;; Restore clients if user pressed C-g in
      `kill-buffer'. (setq server-buffer-clients (list proc)))))))))

      ;; Delete the client's frames.
      (unless noframe
	(dolist (frame (frame-list))
	  (when (and (frame-live-p frame)
		     (equal proc (frame-parameter frame 'client)))
	    ;; Prevent `server-handle-delete-frame' from calling us
	    ;; recursively.
	    (set-frame-parameter frame 'client nil)
	    (delete-frame frame))))

      (setq server-clients (delq proc server-clients))

      ;; Delete the client's tty.
      (let ((terminal (process-get proc 'terminal)))
	;; Only delete the terminal if it is non-nil.
	(when (and terminal (eq (terminal-live-p terminal) t))
	  (delete-terminal terminal)))

      ;; Delete the client's process.
      (if (eq (process-status proc) 'open)
	  (delete-process proc))

      (server-log "Deleted" proc))))
***

When I add this definition to my config files and reload, then
org-protocol-remember works as expected. 

Surely there are still others using emacs 22.3? Is there another way
around this (short of upgrading to emacs 23 -- I might do that, but I'm
so swamped with other things right now and I know so little about
what I'm doing that I don't want to move on that yet)?

-- 
John Rakestraw

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

* Re: org-protocol and missing server-delete-client function
  2009-04-16 20:29 org-protocol and missing server-delete-client function John Rakestraw
@ 2009-04-16 21:09 ` Sebastian Rose
  2009-04-16 23:22 ` Sebastian Rose
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Rose @ 2009-04-16 21:09 UTC (permalink / raw)
  To: John Rakestraw; +Cc: emacs-orgmode

Hi John,


looks like I have to install emacs22 too - it's the current stable...
I wonder which function will delete the client in emacs-22.

Does anyone here know?

I will take a look in emacs 22 and be back.



   Sebastian



John Rakestraw <lists@johnrakestraw.com> writes:
> Hi --
>
> I'm a simple guy, not a coder, and only a little emacs-savvy. However,
> this post might save some people some frustration. (And it might prompt
> someone more emacs-savvy than I to teach me something.)
>
> I faced a challenge getting org-protocol to work.
>
> I'm running the latest org-mode from git on a Fedora 10 box. Emacs
> version 22.3.1. I set up for org-protocol in emacs and in firefox
> (following the instructions at
> http://orgmode.org/worg/org-contrib/org-protocol.php). Then when I
> tried to execute the org-protocol-remember handler, emacs pitched back
> this error message:
>
> ***
> error in process filter: symbol's function definition is void:
> server-delete-client
> ***
>
> I looked in server.el, and didn't find server-delete-client defined
> there. I found a copy of server.el for emacs 23 online at
> http://zchan.homeunix.net/pub/Nevada.APP/Build/emacs-23.0.60/lisp/server.el/server.
> It includes this definition of server-delete-client:
>
> ***
> (defun server-delete-client (proc &optional noframe)
>   "Delete CLIENT, including its buffers, terminals and frames.
> If NOFRAME is non-nil, let the frames live.  (To be used from
> `delete-frame-functions'.)"
>   (server-log (concat "server-delete-client" (if noframe " noframe"))
> 	      proc)
>   ;; Force a new lookup of client (prevents infinite recursion).
>   (when (memq proc server-clients)
>     (let ((buffers (process-get proc 'buffers)))
>
>       ;; Kill the client's buffers.
>       (dolist (buf buffers)
> 	(when (buffer-live-p buf)
> 	  (with-current-buffer buf
> 	    ;; Kill the buffer if necessary.
> 	    (when (and (equal server-buffer-clients
> 			      (list proc))
> 		       (or (and server-kill-new-buffers
> 				(not server-existing-buffer))
> 			   (server-temp-file-p))
> 		       (not (buffer-modified-p)))
> 	      (let (flag)
> 		(unwind-protect
> 		    (progn (setq server-buffer-clients nil)
> 			   (kill-buffer (current-buffer))
> 			   (setq flag t))
> 		  (unless flag
> 		    ;; Restore clients if user pressed C-g in
>       `kill-buffer'. (setq server-buffer-clients (list proc)))))))))
>
>       ;; Delete the client's frames.
>       (unless noframe
> 	(dolist (frame (frame-list))
> 	  (when (and (frame-live-p frame)
> 		     (equal proc (frame-parameter frame 'client)))
> 	    ;; Prevent `server-handle-delete-frame' from calling us
> 	    ;; recursively.
> 	    (set-frame-parameter frame 'client nil)
> 	    (delete-frame frame))))
>
>       (setq server-clients (delq proc server-clients))
>
>       ;; Delete the client's tty.
>       (let ((terminal (process-get proc 'terminal)))
> 	;; Only delete the terminal if it is non-nil.
> 	(when (and terminal (eq (terminal-live-p terminal) t))
> 	  (delete-terminal terminal)))
>
>       ;; Delete the client's process.
>       (if (eq (process-status proc) 'open)
> 	  (delete-process proc))
>
>       (server-log "Deleted" proc))))
> ***
>
> When I add this definition to my config files and reload, then
> org-protocol-remember works as expected. 
>
> Surely there are still others using emacs 22.3? Is there another way
> around this (short of upgrading to emacs 23 -- I might do that, but I'm
> so swamped with other things right now and I know so little about
> what I'm doing that I don't want to move on that yet)?

-- 
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Email: s.rose@emma-stil.de, sebastian_rose@gmx.de
Http:  www.emma-stil.de

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

* Re: org-protocol and missing server-delete-client function
  2009-04-16 20:29 org-protocol and missing server-delete-client function John Rakestraw
  2009-04-16 21:09 ` Sebastian Rose
@ 2009-04-16 23:22 ` Sebastian Rose
  2009-04-17  0:36   ` Sebastian Rose
  1 sibling, 1 reply; 4+ messages in thread
From: Sebastian Rose @ 2009-04-16 23:22 UTC (permalink / raw)
  To: John Rakestraw; +Cc: emacs-orgmode

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


Hi John,


The appended patch should do.


I found, that here (emacs 23) it works, if I replace

  `server-delete-client'

with

   `server-sentinel'


In emacs23, `server-sentinel' calls `server-delete-client'.

I found `server-sentinel' in emacs22 (lisp/server.el) and it seems to do
what we need.

Would you mind to try that?

I will, but haven't compiled emacs22 yet (just have to think a little
about the best setup with two emacs versions).



The sense of the function is to kill the emacsclient and the servers
connection. Otherwise, we would get questions when exiting emacs:

  "Server buffer still has clients. ...."



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-protocol_server-sentinel.patch --]
[-- Type: text/x-diff, Size: 1025 bytes --]

diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index cc99235..8ba906d 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -132,7 +132,8 @@
 		  (&optional refresh))
 (declare-function org-publish-get-project-from-filename "org-publish"
 		  (filename &optional up))
-(declare-function server-delete-client proc "server" (&optional noframe))
+(declare-function server-sentinel "server"
+		  (proc msg))
 
 (defgroup org-protocol nil
   "Intercept calls from emacsclient to trigger custom actions.
@@ -478,7 +479,7 @@ as filename."
                        (splitted (split-string fname proto))
                        (result (if greedy restoffiles (cadr splitted))))
                   (if (plist-get (cdr prolist) :kill-client)
-                      (server-delete-client client t))
+		      (server-sentinel client "Greedy org-protocol handler. Killing client."))
                   (when (fboundp func)
                     (unless greedy
                       (throw 'fname (funcall func result)))

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





Regards


   Sebastian


John Rakestraw <lists@johnrakestraw.com> writes:
> Hi --
>
> I'm a simple guy, not a coder, and only a little emacs-savvy. However,
> this post might save some people some frustration. (And it might prompt
> someone more emacs-savvy than I to teach me something.)
>
> I faced a challenge getting org-protocol to work.
>
> I'm running the latest org-mode from git on a Fedora 10 box. Emacs
> version 22.3.1. I set up for org-protocol in emacs and in firefox
> (following the instructions at
> http://orgmode.org/worg/org-contrib/org-protocol.php). Then when I
> tried to execute the org-protocol-remember handler, emacs pitched back
> this error message:
>
> ***
> error in process filter: symbol's function definition is void:
> server-delete-client
> ***
>
> I looked in server.el, and didn't find server-delete-client defined
> there. I found a copy of server.el for emacs 23 online at
> http://zchan.homeunix.net/pub/Nevada.APP/Build/emacs-23.0.60/lisp/server.el/server.
> It includes this definition of server-delete-client:
>
> ***
> (defun server-delete-client (proc &optional noframe)
>   "Delete CLIENT, including its buffers, terminals and frames.
> If NOFRAME is non-nil, let the frames live.  (To be used from
> `delete-frame-functions'.)"
>   (server-log (concat "server-delete-client" (if noframe " noframe"))
> 	      proc)
>   ;; Force a new lookup of client (prevents infinite recursion).
>   (when (memq proc server-clients)
>     (let ((buffers (process-get proc 'buffers)))
>
>       ;; Kill the client's buffers.
>       (dolist (buf buffers)
> 	(when (buffer-live-p buf)
> 	  (with-current-buffer buf
> 	    ;; Kill the buffer if necessary.
> 	    (when (and (equal server-buffer-clients
> 			      (list proc))
> 		       (or (and server-kill-new-buffers
> 				(not server-existing-buffer))
> 			   (server-temp-file-p))
> 		       (not (buffer-modified-p)))
> 	      (let (flag)
> 		(unwind-protect
> 		    (progn (setq server-buffer-clients nil)
> 			   (kill-buffer (current-buffer))
> 			   (setq flag t))
> 		  (unless flag
> 		    ;; Restore clients if user pressed C-g in
>       `kill-buffer'. (setq server-buffer-clients (list proc)))))))))
>
>       ;; Delete the client's frames.
>       (unless noframe
> 	(dolist (frame (frame-list))
> 	  (when (and (frame-live-p frame)
> 		     (equal proc (frame-parameter frame 'client)))
> 	    ;; Prevent `server-handle-delete-frame' from calling us
> 	    ;; recursively.
> 	    (set-frame-parameter frame 'client nil)
> 	    (delete-frame frame))))
>
>       (setq server-clients (delq proc server-clients))
>
>       ;; Delete the client's tty.
>       (let ((terminal (process-get proc 'terminal)))
> 	;; Only delete the terminal if it is non-nil.
> 	(when (and terminal (eq (terminal-live-p terminal) t))
> 	  (delete-terminal terminal)))
>
>       ;; Delete the client's process.
>       (if (eq (process-status proc) 'open)
> 	  (delete-process proc))
>
>       (server-log "Deleted" proc))))
> ***
>
> When I add this definition to my config files and reload, then
> org-protocol-remember works as expected. 
>
> Surely there are still others using emacs 22.3? Is there another way
> around this (short of upgrading to emacs 23 -- I might do that, but I'm
> so swamped with other things right now and I know so little about
> what I'm doing that I don't want to move on that yet)?

-- 
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Email: s.rose@emma-stil.de, sebastian_rose@gmx.de
Http:  www.emma-stil.de

[-- 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 related	[flat|nested] 4+ messages in thread

* Re: org-protocol and missing server-delete-client function
  2009-04-16 23:22 ` Sebastian Rose
@ 2009-04-17  0:36   ` Sebastian Rose
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Rose @ 2009-04-17  0:36 UTC (permalink / raw)
  To: John Rakestraw; +Cc: emacs-orgmode


Just installed emacs22 and I see, it's not that easy.
The client argument has the wrong type or something when emacs22.
So I'll have to investigate some more...


Best,

   Sebastian


Sebastian Rose <sebastian_rose@gmx.de> writes:
> Hi John,
>
>
> The appended patch should do.
>
>
> I found, that here (emacs 23) it works, if I replace
>
>   `server-delete-client'
>
> with
>
>    `server-sentinel'
>
>
> In emacs23, `server-sentinel' calls `server-delete-client'.
>
> I found `server-sentinel' in emacs22 (lisp/server.el) and it seems to do
> what we need.
>
> Would you mind to try that?
>
> I will, but haven't compiled emacs22 yet (just have to think a little
> about the best setup with two emacs versions).
>
>
>
> The sense of the function is to kill the emacsclient and the servers
> connection. Otherwise, we would get questions when exiting emacs:
>
>   "Server buffer still has clients. ...."
>
>
>
> diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
> index cc99235..8ba906d 100644
> --- a/lisp/org-protocol.el
> +++ b/lisp/org-protocol.el
> @@ -132,7 +132,8 @@
>  		  (&optional refresh))
>  (declare-function org-publish-get-project-from-filename "org-publish"
>  		  (filename &optional up))
> -(declare-function server-delete-client proc "server" (&optional noframe))
> +(declare-function server-sentinel "server"
> +		  (proc msg))
>  
>  (defgroup org-protocol nil
>    "Intercept calls from emacsclient to trigger custom actions.
> @@ -478,7 +479,7 @@ as filename."
>                         (splitted (split-string fname proto))
>                         (result (if greedy restoffiles (cadr splitted))))
>                    (if (plist-get (cdr prolist) :kill-client)
> -                      (server-delete-client client t))
> +		      (server-sentinel client "Greedy org-protocol handler. Killing client."))
>                    (when (fboundp func)
>                      (unless greedy
>                        (throw 'fname (funcall func result)))
>
>
>
>
>
> Regards
>
>
>    Sebastian
>
>
> John Rakestraw <lists@johnrakestraw.com> writes:
>> Hi --
>>
>> I'm a simple guy, not a coder, and only a little emacs-savvy. However,
>> this post might save some people some frustration. (And it might prompt
>> someone more emacs-savvy than I to teach me something.)
>>
>> I faced a challenge getting org-protocol to work.
>>
>> I'm running the latest org-mode from git on a Fedora 10 box. Emacs
>> version 22.3.1. I set up for org-protocol in emacs and in firefox
>> (following the instructions at
>> http://orgmode.org/worg/org-contrib/org-protocol.php). Then when I
>> tried to execute the org-protocol-remember handler, emacs pitched back
>> this error message:
>>
>> ***
>> error in process filter: symbol's function definition is void:
>> server-delete-client
>> ***
>>
>> I looked in server.el, and didn't find server-delete-client defined
>> there. I found a copy of server.el for emacs 23 online at
>> http://zchan.homeunix.net/pub/Nevada.APP/Build/emacs-23.0.60/lisp/server.el/server.
>> It includes this definition of server-delete-client:
>>
>> ***
>> (defun server-delete-client (proc &optional noframe)
>>   "Delete CLIENT, including its buffers, terminals and frames.
>> If NOFRAME is non-nil, let the frames live.  (To be used from
>> `delete-frame-functions'.)"
>>   (server-log (concat "server-delete-client" (if noframe " noframe"))
>> 	      proc)
>>   ;; Force a new lookup of client (prevents infinite recursion).
>>   (when (memq proc server-clients)
>>     (let ((buffers (process-get proc 'buffers)))
>>
>>       ;; Kill the client's buffers.
>>       (dolist (buf buffers)
>> 	(when (buffer-live-p buf)
>> 	  (with-current-buffer buf
>> 	    ;; Kill the buffer if necessary.
>> 	    (when (and (equal server-buffer-clients
>> 			      (list proc))
>> 		       (or (and server-kill-new-buffers
>> 				(not server-existing-buffer))
>> 			   (server-temp-file-p))
>> 		       (not (buffer-modified-p)))
>> 	      (let (flag)
>> 		(unwind-protect
>> 		    (progn (setq server-buffer-clients nil)
>> 			   (kill-buffer (current-buffer))
>> 			   (setq flag t))
>> 		  (unless flag
>> 		    ;; Restore clients if user pressed C-g in
>>       `kill-buffer'. (setq server-buffer-clients (list proc)))))))))
>>
>>       ;; Delete the client's frames.
>>       (unless noframe
>> 	(dolist (frame (frame-list))
>> 	  (when (and (frame-live-p frame)
>> 		     (equal proc (frame-parameter frame 'client)))
>> 	    ;; Prevent `server-handle-delete-frame' from calling us
>> 	    ;; recursively.
>> 	    (set-frame-parameter frame 'client nil)
>> 	    (delete-frame frame))))
>>
>>       (setq server-clients (delq proc server-clients))
>>
>>       ;; Delete the client's tty.
>>       (let ((terminal (process-get proc 'terminal)))
>> 	;; Only delete the terminal if it is non-nil.
>> 	(when (and terminal (eq (terminal-live-p terminal) t))
>> 	  (delete-terminal terminal)))
>>
>>       ;; Delete the client's process.
>>       (if (eq (process-status proc) 'open)
>> 	  (delete-process proc))
>>
>>       (server-log "Deleted" proc))))
>> ***
>>
>> When I add this definition to my config files and reload, then
>> org-protocol-remember works as expected. 
>>
>> Surely there are still others using emacs 22.3? Is there another way
>> around this (short of upgrading to emacs 23 -- I might do that, but I'm
>> so swamped with other things right now and I know so little about
>> what I'm doing that I don't want to move on that yet)?

-- 
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Email: s.rose@emma-stil.de, sebastian_rose@gmx.de
Http:  www.emma-stil.de

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

end of thread, other threads:[~2009-04-17  0:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 20:29 org-protocol and missing server-delete-client function John Rakestraw
2009-04-16 21:09 ` Sebastian Rose
2009-04-16 23:22 ` Sebastian Rose
2009-04-17  0:36   ` Sebastian Rose

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