From mboxrd@z Thu Jan 1 00:00:00 1970 From: Torsten Wagner Subject: Announce first mockup for org-server Date: Thu, 17 Feb 2011 14:41:42 +0900 Message-ID: <4D5CB516.7080706@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050707060106050308090400" Return-path: Received: from [140.186.70.92] (port=43405 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ppwch-00005n-Aw for emacs-orgmode@gnu.org; Thu, 17 Feb 2011 00:41:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ppwcf-0006J0-12 for emacs-orgmode@gnu.org; Thu, 17 Feb 2011 00:41:51 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:58911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ppwce-0006Ir-NJ for emacs-orgmode@gnu.org; Thu, 17 Feb 2011 00:41:48 -0500 Received: by pwj8 with SMTP id 8so436003pwj.0 for ; Wed, 16 Feb 2011 21:41:47 -0800 (PST) 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: Org Mode Mailing List This is a multi-part message in MIME format. --------------050707060106050308090400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dear all, based on the discussions of a google calendar sync http://thread.gmane.org/gmane.emacs.orgmode/36517/focus=36754 and about Taskwarrior a command line org-mode like program http://thread.gmane.org/gmane.emacs.orgmode/37020/focus=37076 a discussion started why not running emacs as an org-mode server and to define a command interface to directly communicate with org-mode. A well defined API for such an server would have several benefits: * External programs like orgmobile for Android and Iphone would not need to emulate well tested org-mode functions. They could simply order the server to execute them and send back the results (e.g. compile agenda). * Mobile devices might save resources and battery power by not running emacs natively. This would work on devices without emacs. * People could design different user-interfaces for different needs (e.g., mobile, web, widgets, command line) still using a full featured regular org-mode. * Integration with other programs might be much easier (third party programs e.g., Taskwarrior just need to follow the API to communicate with org-mode) * A server approach does not exclude running emacs natively on the device, instead of a full server address, 'localhost' could be used. Thus, it would be very easy to get a "offline" version for devices which can run emacs natively. Furthermore, emacs itself would be still one (the main) interface to org-mode. * This is much different usage scenario then the org-export options, which basically transform org-mode files into another format. org-server should help to interactively communicate with org-mode. Thinking about this for some time, I looked around and found the possibility of emacs (starting from emacs 22) to operate as server listing to certain ports. I started a bit testing to see how server-communication in emacs looks like and ended up with a very very basic communication. Even totally practically unusable (there is no functionality yet) I thought that even at this early state it does not make much sense to keep it away from you. An API definition to communicate requires deep integration into org-mode and well thoughts how such a API might look like. This is something which requires intensive discussion and a good overview of org-mode internals (which I don't have). Please find attached a first mock-up which demonstrates org-server communication. Usage: 1. Copy org-server.el somewhere 2. Open in emacs and evaluate the buffer (or use another method to evaluate the file) 3. M-x org-server-start starts the org-server 4. Use a command line or a GUI based telnet client 5. Connect to localhost (127.0.0.1) and port 8051 (you can change the port in org-server.el if you need to use a different port) 6. Type something, press enter 7. To stop the server type M-x org-server-stop If the command is recognized to be one of those org-next-agenda org-search-header org-tag-search org-add-note org-add-tag org-remove-tag org-todo-sets (all just made up without real functionality) a message will be printed. If not the command will be rejected with a error message. Again there is no function yet. It should simply demonstrate the possibility to receive and send commands to org-mode via a network connection. 99% of the code is copied from http://www.emacswiki.org/emacs/EmacsEchoServer I would like to express my thanks to the original author. I would like to hear your ideas or even better your reports by playing around with it. I still have not much of an idea of elisp and org-mode internals and if many people here like the idea, maybe someone more capable would like to join or takeover to make all this happen... All the best With best regards Torsten --------------050707060106050308090400 Content-Type: text/plain; name="org-server.el" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="org-server.el" ;;; org-server.el --- A server mode for Emacs Org-mode ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. ;; ;; Author: Torsten Wagner ;; Keywords: server, mobile, web, network ;; Homepage: http://orgmode.org ;; Version: 7.4 ;; ;; This file is part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;; Commentary: ;; 2002/02/17 NO RELEASE YET !!!! This is just a very early mockup (even not alpha) ;; with no functionallity purely created for discussions on orgmode ;; mailing list. The code is 99% plain copied from ;; http://www.emacswiki.org/emacs/EmacsEchoServer ;; Kudos to the original author. (defvar org-server-port 8051 "port of the org server") (defvar org-server-clients '() "a list where KEY is a client process and VALUE is the string") (defvar org-server-commands '(org-next-agenda org-search-header org-tag-search org-add-note org-add-tag org-remove-tag org-todo-sets) "a list of possiple commands which can be executed by org-server") (defun org-server-start nil "starts an emacs org server" (interactive) (unless (process-status "org-server") (make-network-process :name "org-server" :buffer "*org-server*" :family 'ipv4 :service org-server-port :sentinel 'org-server-sentinel :filter 'org-server-filter :server 't) (setq org-server-clients '()) ) ) (defun org-server-stop nil "stop an emacs org server" (interactive) (while org-server-clients (delete-process (car (car org-server-clients))) (setq org-server-clients (cdr org-server-clients))) (delete-process "org-server") ) (defun org-server-filter (proc string) (let ((pending (assoc proc org-server-clients)) message index cmd) ;;create entry if required (unless pending (setq org-server-clients (cons (cons proc "") org-server-clients)) (setq pending (assoc proc org-server-clients))) (setq message (concat (cdr pending) string)) (while (setq index (string-match "\n" message)) (setq index (1+ index)) ;;test if the received message is a legal org-command (sanity check) (if (setq cmd (car (member (substring message 0 (- index 2)) (mapcar #'symbol-name org-server-commands)))) (progn ;demo mode just output it would be ok (process-send-string proc (concat (substring message 0 (- index 2)) " command would be avaiable\nMagically things would happen and wise results and answers would be send back\n")) (org-server-log (substring message 0 index) proc) ) (progn ;demo mode just output it is not ok (process-send-string proc "command not avaiable\n") (org-server-log (substring message 0 index) proc) )) (setq message (substring message index)) ) (setcdr pending message)) ) (defun org-server-sentinel (proc msg) (delq proc org-server-clients) (org-server-log (format "client %s has quit" proc))) ;;from server.el (defun org-server-log (string &optional client) "If a *org-server* buffer exists, write STRING to it for logging purposes." (if (get-buffer "*org-server*") (with-current-buffer "*org-server*" (goto-char (point-max)) (insert (current-time-string) (if client (format " %s:" client) " ") string) (or (bolp) (newline))))) --------------050707060106050308090400 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --------------050707060106050308090400--