emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 1/2] org-babel-oz: Fix line-endings.
@ 2010-03-01 13:49 Dan Hackney
  2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
  2010-03-01 15:31 ` [PATCH 1/2] org-babel-oz: Fix line-endings Eric Schulte
  0 siblings, 2 replies; 14+ messages in thread
From: Dan Hackney @ 2010-03-01 13:49 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Dan Hackney

Switch from Windows to Unix line-endings.

Signed-off-by: Dan Hackney <dan@haxney.org>
---
 contrib/babel/lisp/langs/org-babel-oz.el |  618 +++++++++++++++---------------
 1 files changed, 309 insertions(+), 309 deletions(-)

diff --git a/contrib/babel/lisp/langs/org-babel-oz.el b/contrib/babel/lisp/langs/org-babel-oz.el
index 31b3bff..e81787b 100644
--- a/contrib/babel/lisp/langs/org-babel-oz.el
+++ b/contrib/babel/lisp/langs/org-babel-oz.el
@@ -1,309 +1,309 @@
-;;; org-babel-oz.el --- org-babel functions for Oz evaluation
-
-;; Copyright (C) 2009 Torsten Anders and Eric Schulte 
-
-;; Author: Torsten Anders and Eric Schulte 
-;; Keywords: literate programming, reproducible research
-;; Homepage: http://orgmode.org
-;; Version: 0.01
-
-;;; License:
-
-;; This program 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, or (at your option)
-;; any later version.
-;;
-;; This program 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; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; Org-Babel support for evaluating Oz source code. 
-;;
-;; Oz code is always send to the Oz Programming Environment (OPI), the
-;; Emacs mode and compiler interface for Oz programs. Therefore, only
-;; session mode is supported. In practice, non-session code blocks are
-;; handled equally well by the session mode. However, only a single
-;; session is supported. Consequently, the :session header argument is
-;; ignored.
-;;
-;; The Org-babel header argument :results is interpreted as
-;; follows. :results output requires the respective code block to be
-;; an Oz statement and :results value requires an Oz
-;; expression. Currently, results are only supported for expressions
-;; (i.e. the result of :results output is always nil).
-;;
-;; Expression evaluation happens synchronously. Therefore there is an
-;; additional header argument :wait-time <number>, which specifies the
-;; maximum time to wait for the result of a given expression. nil
-;; means to wait as long as it takes to get a result (potentially wait
-;; forever).
-;;
-;; NOTE: Currently the copyright of this file may not be in a state to
-;;       permit inclusion as core software into Emacs or Org-mode.
-
-;;; Requirements:
-
-;; - Mozart Programming System, the implementation of the Oz
-;;   programming language (http://www.mozart-oz.org/), which includes
-;;   the major mode mozart for editing Oz programs.
-;;
-;; - StartOzServer.oz which is located in the contrib/scripts
-;;   directory of the Org-mode repository
-
-;;; TODO:
-
-;; - Decide: set communication to \\switch -threadedqueries?
-;;
-;; - Only start Oz compiler when required, e.g., load Org-babel only when needed?
-;;
-;; - Avoid synchronous evaluation to avoid blocking Emacs (complex
-;;   Strasheela programs can take long to find a result..). In order
-;;   to cleanly map code blocks to their associated results (which can
-;;   arrive then in any order) I could use IDs
-;;   (e.g. integers). However, how do I do concurrency in Emacs Lisp,
-;;   and how can I define org-babel-execute:oz concurrently.
-;; 
-;; - Expressions are rarely used in Oz at the top-level, and using
-;;   them in documentation and Literate Programs will cause
-;;   confusion. Idea: hide expression from reader and instead show
-;;   them statement (e.g., MIDI output statement) and then include
-;;   result in Org file. Implementation: for expressions (:results
-;;   value) support an additional header argument that takes arbitrary
-;;   Oz code. This code is not seen by the reader, but will be used
-;;   for the actual expression at the end.  Alternative: feed all
-;;   relevant code as statement (:results output), then add expression
-;;   as extra code block which outputs, e.g., file name (so the file
-;;   name must be accessible by global var), but the code of this
-;;   extra codeblock is not seen.  Hm, in that case it might be even
-;;   more easy to manually add this link to the Org file.
-;;
-
-
-(require 'org-babel)
-;;; major mode for editing Oz programs
-(require 'mozart)
-
-;; Add Oz to the list of supported languages.  Org-babel will match
-;; the string below against the declared language of the source-code
-;; block.
-(org-babel-add-interpreter "oz")
-
-;; specify the name and file extension for Oz
-(add-to-list 'org-babel-tangle-langs '("oz" "oz" nil nil))
-
-;;
-;; Interface to communicate with Oz.
-;; (1) For statements without any results: oz-send-string 
-;; (2) For expressions with a single result: oz-send-string-expression
-;;     (defined in org-babel-oz-ResultsValue.el)
-;; 
-
-;; oz-send-string-expression implements an additional very direct
-;; communication between Org-babel and the Oz compiler. Communication
-;; with the Oz server works already without this code via the function
-;; oz-send-string from mozart.el.in, but this function does not get
-;; back any results from Oz to Emacs. The following code creates a
-;; socket for sending code to the OPI compiler and results are
-;; returned by the same socket. On the Oz side, a socket is opened and
-;; conected to the compiler of the OPI (via oz-send-string). On the
-;; Emacs side, a connection to this socket is created for feeding code
-;; and receiving results. This additional communication channel to the
-;; OPI compiler ensures that results are returned cleanly (e.g., only
-;; the result of the sent code is returned, no parsing or any
-;; processing of *Oz Emulator* is required).
-;;
-;; There is no buffer, nor sentinel involved. Oz code is send
-;; directly, and results from Oz are send back, but Emacs Lisp
-;; requires a filter function for processing results.
-
-(defvar org-babel-oz-server-dir
-  (file-name-as-directory
-   (expand-file-name
-    "scripts"
-    (file-name-as-directory
-     (expand-file-name
-      "../../.."
-      (file-name-directory (or load-file-name buffer-file-name))))))
-  "Path to the contrib/scripts directory in which
-StartOzServer.oz is located.")
-
-(defvar org-babel-oz-port 6001		
-  "Port for communicating with Oz compiler.")
-(defvar org-babel-oz-OPI-socket nil
-  "Socket for communicating with OPI.")
-
-(defvar org-babel-oz-collected-result nil
-  "Aux var to hand result from org-babel-oz-filter to oz-send-string-expression.")
-(defun org-babel-oz-filter (proc string)
-  "Processes output from socket org-babel-oz-OPI-socket."
-;;   (setq org-babel-oz-collected-results (cons string org-babel-oz-collected-results))
-  (setq org-babel-oz-collected-result string)
-  )
-
-
-(defun org-babel-oz-create-socket ()
-  (message "Create OPI socket for evaluating expressions")
-  ;; Start Oz directly 
-  (run-oz)
-  ;; Create socket on Oz side (after Oz was started).
-  (oz-send-string (concat "\\insert '" org-babel-oz-server-dir "StartOzServer.oz'"))
-  ;; Wait until socket is created before connecting to it.
-  ;; Quick hack: wait 3 sec
-  ;; 
-  ;; extending time to 30 secs does not help when starting Emacs for
-  ;; the first time (and computer does nothing else)
-  (sit-for 3)
-  ;; connect to OPI socket
-  (setq org-babel-oz-OPI-socket  
-	;; Creates a socket. I/O interface of Emacs sockets as for processes.
-	(open-network-stream "*Org-babel-OPI-socket*" nil "localhost" org-babel-oz-port))
-  ;; install filter
-  (set-process-filter org-babel-oz-OPI-socket #'org-babel-oz-filter)
-)
-
-;; communication with org-babel-oz-OPI-socket is asynchronous, but
-;; oz-send-string-expression turns is into synchronous...
-(defun oz-send-string-expression (string &optional wait-time)
-  "Similar to oz-send-string, oz-send-string-expression sends a string to the OPI compiler. However, string must be expression and this function returns the result of the expression (as string). oz-send-string-expression is synchronous, wait-time allows to specify a maximum wait time. After wait-time is over with no result, the function returns nil."
-  (if (not org-babel-oz-OPI-socket) 
-      (org-babel-oz-create-socket))
-  (let ((polling-delay 0.1)
-	result)
-    (process-send-string org-babel-oz-OPI-socket string)
-    ;; wait for result
-    (if wait-time
-	(let ((waited 0))
-	  (unwind-protect
-	      (progn
-		(while 
-		    ;; stop loop if org-babel-oz-collected-result \= nil or waiting time is over
-		    (not (or (not (equal org-babel-oz-collected-result nil))
-			     (> waited wait-time)))
-		  (progn 
-		    (sit-for polling-delay)
-;; 		    (message "org-babel-oz: next polling iteration")
-		    (setq waited (+ waited polling-delay))))
-;; 		(message "org-babel-oz: waiting over, got result or waiting timed out")
-;; 		(message (format "wait-time: %s, waited: %s" wait-time waited))
-		(setq result org-babel-oz-collected-result)
-		(setq org-babel-oz-collected-result nil))))
-      (unwind-protect
-	  (progn
-	    (while (equal org-babel-oz-collected-result nil)
-	      (sit-for polling-delay))
-	    (setq result org-babel-oz-collected-result)
-	    (setq org-babel-oz-collected-result nil))))
-    result))
-
-
-(defun org-babel-execute:oz (body params)
-  "Execute a block of Oz code with org-babel.  This function is
-called by `org-babel-execute-src-block' via multiple-value-bind."
-  (let* ((processed-params (org-babel-process-params params))
-;; 	(session (org-babel-ruby-initiate-session (first processed-params)))
-	(vars (second processed-params))
-;; 	(result-params (third processed-params))
-	(result-type (fourth processed-params))
-	(full-body (if vars
-		       ;; only add var declarations if any variables are there
-		     (concat
-		      ;; prepend code to define all arguments passed to the code block
-		      "local\n"
-		      (mapconcat
-		       (lambda (pair)
-			 (format "%s=%s"
-				 (car pair)
-				 (org-babel-oz-var-to-oz (cdr pair))))
-		       vars "\n") "\n" 
-		       "in\n"
-		       body 
-		       "end\n")
-		     body))
-	(wait-time (plist-get params :wait-time))
-        ;; set the session if the session variable is non-nil
-;; 	(session-buffer (org-babel-oz-initiate-session session))
-;; 	(session (org-babel-prep-session:oz session params))
-	)
-    ;; actually execute the source-code block 
-     (case result-type
-       (output
-	(progn 
-	  (message "Org-babel: executing Oz statement")
-	  (oz-send-string full-body)))
-       (value
-	(progn 
-	  (message "Org-babel: executing Oz expression")
-	  (oz-send-string-expression full-body (if wait-time
-						   wait-time
-						 1)))))
-    ))
-
-;; This function should be used to assign any variables in params in
-;; the context of the session environment.
-(defun org-babel-prep-session:oz (session params)
-  "Prepare SESSION according to the header arguments specified in PARAMS."
-  (error "org-babel-prep-session:oz unimplemented"))
-;; TODO: testing... (copied from org-babel-haskell.el)
-;; (defun org-babel-prep-session:oz (session params)
-;;   "Prepare SESSION according to the header arguments specified in PARAMS."
-;;   (save-window-excursion
-;;     (org-babel-oz-initiate-session session)
-;;     (let* ((vars (org-babel-ref-variables params))
-;;            (var-lines (mapconcat ;; define any variables
-;;                        (lambda (pair)
-;;                          (format "%s=%s"
-;;                                  (car pair)
-;;                                  (org-babel-ruby-var-to-ruby (cdr pair))))
-;;                        vars "\n"))
-;;            (vars-file (concat (make-temp-file "org-babel-oz-vars") ".oz")))
-;;       (when vars
-;;         (with-temp-buffer
-;;           (insert var-lines) (write-file vars-file)
-;;           (oz-mode) 
-;; ;; 	  (inferior-oz-load-file) ; ??
-;; 	  ))
-;;       (current-buffer))))
-;;
-
-
-;; TODO: testing... (simplified version of def in org-babel-prep-session:ocaml)
-;;
-;; BUG: does not work yet. Error: ad-Orig-error: buffer none doesn't exist or has no process 
-;; UNUSED DEF
-(defun org-babel-oz-initiate-session (&optional session)
-  "If there is not a current inferior-process-buffer in SESSION
-then create.  Return the initialized session."
-  (unless (string= session "none")
-    ;; TODO: make it possible to have multiple sessions
-    (save-window-excursion
-      ;; (run-oz)
-      (get-buffer oz-compiler-buffer))))
-
-(defun org-babel-oz-var-to-oz (var)
-  "Convert an elisp var into a string of Oz source code
-specifying a var of the same value."
-  (if (listp var)
-;;       (concat "[" (mapconcat #'org-babel-oz-var-to-oz var ", ") "]")
-      (eval var) 
-    (format "%s" var) ; don't preserve string quotes. 
-;;     (format "%s" var)
-    ))
-
-;; TODO: 
-(defun org-babel-oz-table-or-string (results)
-  "If the results look like a table, then convert them into an
-Emacs-lisp table, otherwise return the results as a string."
-  (error "org-babel-oz-table-or-string unimplemented"))
-
-
-(provide 'org-babel-oz)
-;;; org-babel-oz.el ends here
+;;; org-babel-oz.el --- org-babel functions for Oz evaluation
+
+;; Copyright (C) 2009 Torsten Anders and Eric Schulte
+
+;; Author: Torsten Anders and Eric Schulte
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+;; Version: 0.01
+
+;;; License:
+
+;; This program 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, or (at your option)
+;; any later version.
+;;
+;; This program 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; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating Oz source code.
+;;
+;; Oz code is always send to the Oz Programming Environment (OPI), the
+;; Emacs mode and compiler interface for Oz programs. Therefore, only
+;; session mode is supported. In practice, non-session code blocks are
+;; handled equally well by the session mode. However, only a single
+;; session is supported. Consequently, the :session header argument is
+;; ignored.
+;;
+;; The Org-babel header argument :results is interpreted as
+;; follows. :results output requires the respective code block to be
+;; an Oz statement and :results value requires an Oz
+;; expression. Currently, results are only supported for expressions
+;; (i.e. the result of :results output is always nil).
+;;
+;; Expression evaluation happens synchronously. Therefore there is an
+;; additional header argument :wait-time <number>, which specifies the
+;; maximum time to wait for the result of a given expression. nil
+;; means to wait as long as it takes to get a result (potentially wait
+;; forever).
+;;
+;; NOTE: Currently the copyright of this file may not be in a state to
+;;       permit inclusion as core software into Emacs or Org-mode.
+
+;;; Requirements:
+
+;; - Mozart Programming System, the implementation of the Oz
+;;   programming language (http://www.mozart-oz.org/), which includes
+;;   the major mode mozart for editing Oz programs.
+;;
+;; - StartOzServer.oz which is located in the contrib/scripts
+;;   directory of the Org-mode repository
+
+;;; TODO:
+
+;; - Decide: set communication to \\switch -threadedqueries?
+;;
+;; - Only start Oz compiler when required, e.g., load Org-babel only when needed?
+;;
+;; - Avoid synchronous evaluation to avoid blocking Emacs (complex
+;;   Strasheela programs can take long to find a result..). In order
+;;   to cleanly map code blocks to their associated results (which can
+;;   arrive then in any order) I could use IDs
+;;   (e.g. integers). However, how do I do concurrency in Emacs Lisp,
+;;   and how can I define org-babel-execute:oz concurrently.
+;;
+;; - Expressions are rarely used in Oz at the top-level, and using
+;;   them in documentation and Literate Programs will cause
+;;   confusion. Idea: hide expression from reader and instead show
+;;   them statement (e.g., MIDI output statement) and then include
+;;   result in Org file. Implementation: for expressions (:results
+;;   value) support an additional header argument that takes arbitrary
+;;   Oz code. This code is not seen by the reader, but will be used
+;;   for the actual expression at the end.  Alternative: feed all
+;;   relevant code as statement (:results output), then add expression
+;;   as extra code block which outputs, e.g., file name (so the file
+;;   name must be accessible by global var), but the code of this
+;;   extra codeblock is not seen.  Hm, in that case it might be even
+;;   more easy to manually add this link to the Org file.
+;;
+
+
+(require 'org-babel)
+;;; major mode for editing Oz programs
+(require 'mozart)
+
+;; Add Oz to the list of supported languages.  Org-babel will match
+;; the string below against the declared language of the source-code
+;; block.
+(org-babel-add-interpreter "oz")
+
+;; specify the name and file extension for Oz
+(add-to-list 'org-babel-tangle-langs '("oz" "oz" nil nil))
+
+;;
+;; Interface to communicate with Oz.
+;; (1) For statements without any results: oz-send-string
+;; (2) For expressions with a single result: oz-send-string-expression
+;;     (defined in org-babel-oz-ResultsValue.el)
+;;
+
+;; oz-send-string-expression implements an additional very direct
+;; communication between Org-babel and the Oz compiler. Communication
+;; with the Oz server works already without this code via the function
+;; oz-send-string from mozart.el.in, but this function does not get
+;; back any results from Oz to Emacs. The following code creates a
+;; socket for sending code to the OPI compiler and results are
+;; returned by the same socket. On the Oz side, a socket is opened and
+;; conected to the compiler of the OPI (via oz-send-string). On the
+;; Emacs side, a connection to this socket is created for feeding code
+;; and receiving results. This additional communication channel to the
+;; OPI compiler ensures that results are returned cleanly (e.g., only
+;; the result of the sent code is returned, no parsing or any
+;; processing of *Oz Emulator* is required).
+;;
+;; There is no buffer, nor sentinel involved. Oz code is send
+;; directly, and results from Oz are send back, but Emacs Lisp
+;; requires a filter function for processing results.
+
+(defvar org-babel-oz-server-dir
+  (file-name-as-directory
+   (expand-file-name
+    "scripts"
+    (file-name-as-directory
+     (expand-file-name
+      "../../.."
+      (file-name-directory (or load-file-name buffer-file-name))))))
+  "Path to the contrib/scripts directory in which
+StartOzServer.oz is located.")
+
+(defvar org-babel-oz-port 6001
+  "Port for communicating with Oz compiler.")
+(defvar org-babel-oz-OPI-socket nil
+  "Socket for communicating with OPI.")
+
+(defvar org-babel-oz-collected-result nil
+  "Aux var to hand result from org-babel-oz-filter to oz-send-string-expression.")
+(defun org-babel-oz-filter (proc string)
+  "Processes output from socket org-babel-oz-OPI-socket."
+;;   (setq org-babel-oz-collected-results (cons string org-babel-oz-collected-results))
+  (setq org-babel-oz-collected-result string)
+  )
+
+
+(defun org-babel-oz-create-socket ()
+  (message "Create OPI socket for evaluating expressions")
+  ;; Start Oz directly
+  (run-oz)
+  ;; Create socket on Oz side (after Oz was started).
+  (oz-send-string (concat "\\insert '" org-babel-oz-server-dir "StartOzServer.oz'"))
+  ;; Wait until socket is created before connecting to it.
+  ;; Quick hack: wait 3 sec
+  ;;
+  ;; extending time to 30 secs does not help when starting Emacs for
+  ;; the first time (and computer does nothing else)
+  (sit-for 3)
+  ;; connect to OPI socket
+  (setq org-babel-oz-OPI-socket
+	;; Creates a socket. I/O interface of Emacs sockets as for processes.
+	(open-network-stream "*Org-babel-OPI-socket*" nil "localhost" org-babel-oz-port))
+  ;; install filter
+  (set-process-filter org-babel-oz-OPI-socket #'org-babel-oz-filter)
+)
+
+;; communication with org-babel-oz-OPI-socket is asynchronous, but
+;; oz-send-string-expression turns is into synchronous...
+(defun oz-send-string-expression (string &optional wait-time)
+  "Similar to oz-send-string, oz-send-string-expression sends a string to the OPI compiler. However, string must be expression and this function returns the result of the expression (as string). oz-send-string-expression is synchronous, wait-time allows to specify a maximum wait time. After wait-time is over with no result, the function returns nil."
+  (if (not org-babel-oz-OPI-socket)
+      (org-babel-oz-create-socket))
+  (let ((polling-delay 0.1)
+	result)
+    (process-send-string org-babel-oz-OPI-socket string)
+    ;; wait for result
+    (if wait-time
+	(let ((waited 0))
+	  (unwind-protect
+	      (progn
+		(while
+		    ;; stop loop if org-babel-oz-collected-result \= nil or waiting time is over
+		    (not (or (not (equal org-babel-oz-collected-result nil))
+			     (> waited wait-time)))
+		  (progn
+		    (sit-for polling-delay)
+;; 		    (message "org-babel-oz: next polling iteration")
+		    (setq waited (+ waited polling-delay))))
+;; 		(message "org-babel-oz: waiting over, got result or waiting timed out")
+;; 		(message (format "wait-time: %s, waited: %s" wait-time waited))
+		(setq result org-babel-oz-collected-result)
+		(setq org-babel-oz-collected-result nil))))
+      (unwind-protect
+	  (progn
+	    (while (equal org-babel-oz-collected-result nil)
+	      (sit-for polling-delay))
+	    (setq result org-babel-oz-collected-result)
+	    (setq org-babel-oz-collected-result nil))))
+    result))
+
+
+(defun org-babel-execute:oz (body params)
+  "Execute a block of Oz code with org-babel.  This function is
+called by `org-babel-execute-src-block' via multiple-value-bind."
+  (let* ((processed-params (org-babel-process-params params))
+;; 	(session (org-babel-ruby-initiate-session (first processed-params)))
+	(vars (second processed-params))
+;; 	(result-params (third processed-params))
+	(result-type (fourth processed-params))
+	(full-body (if vars
+		       ;; only add var declarations if any variables are there
+		     (concat
+		      ;; prepend code to define all arguments passed to the code block
+		      "local\n"
+		      (mapconcat
+		       (lambda (pair)
+			 (format "%s=%s"
+				 (car pair)
+				 (org-babel-oz-var-to-oz (cdr pair))))
+		       vars "\n") "\n"
+		       "in\n"
+		       body
+		       "end\n")
+		     body))
+	(wait-time (plist-get params :wait-time))
+        ;; set the session if the session variable is non-nil
+;; 	(session-buffer (org-babel-oz-initiate-session session))
+;; 	(session (org-babel-prep-session:oz session params))
+	)
+    ;; actually execute the source-code block
+     (case result-type
+       (output
+	(progn
+	  (message "Org-babel: executing Oz statement")
+	  (oz-send-string full-body)))
+       (value
+	(progn
+	  (message "Org-babel: executing Oz expression")
+	  (oz-send-string-expression full-body (if wait-time
+						   wait-time
+						 1)))))
+    ))
+
+;; This function should be used to assign any variables in params in
+;; the context of the session environment.
+(defun org-babel-prep-session:oz (session params)
+  "Prepare SESSION according to the header arguments specified in PARAMS."
+  (error "org-babel-prep-session:oz unimplemented"))
+;; TODO: testing... (copied from org-babel-haskell.el)
+;; (defun org-babel-prep-session:oz (session params)
+;;   "Prepare SESSION according to the header arguments specified in PARAMS."
+;;   (save-window-excursion
+;;     (org-babel-oz-initiate-session session)
+;;     (let* ((vars (org-babel-ref-variables params))
+;;            (var-lines (mapconcat ;; define any variables
+;;                        (lambda (pair)
+;;                          (format "%s=%s"
+;;                                  (car pair)
+;;                                  (org-babel-ruby-var-to-ruby (cdr pair))))
+;;                        vars "\n"))
+;;            (vars-file (concat (make-temp-file "org-babel-oz-vars") ".oz")))
+;;       (when vars
+;;         (with-temp-buffer
+;;           (insert var-lines) (write-file vars-file)
+;;           (oz-mode)
+;; ;; 	  (inferior-oz-load-file) ; ??
+;; 	  ))
+;;       (current-buffer))))
+;;
+
+
+;; TODO: testing... (simplified version of def in org-babel-prep-session:ocaml)
+;;
+;; BUG: does not work yet. Error: ad-Orig-error: buffer none doesn't exist or has no process
+;; UNUSED DEF
+(defun org-babel-oz-initiate-session (&optional session)
+  "If there is not a current inferior-process-buffer in SESSION
+then create.  Return the initialized session."
+  (unless (string= session "none")
+    ;; TODO: make it possible to have multiple sessions
+    (save-window-excursion
+      ;; (run-oz)
+      (get-buffer oz-compiler-buffer))))
+
+(defun org-babel-oz-var-to-oz (var)
+  "Convert an elisp var into a string of Oz source code
+specifying a var of the same value."
+  (if (listp var)
+;;       (concat "[" (mapconcat #'org-babel-oz-var-to-oz var ", ") "]")
+      (eval var)
+    (format "%s" var) ; don't preserve string quotes.
+;;     (format "%s" var)
+    ))
+
+;; TODO:
+(defun org-babel-oz-table-or-string (results)
+  "If the results look like a table, then convert them into an
+Emacs-lisp table, otherwise return the results as a string."
+  (error "org-babel-oz-table-or-string unimplemented"))
+
+
+(provide 'org-babel-oz)
+;;; org-babel-oz.el ends here
-- 
1.6.3.3

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

* [PATCH 2/2] Fix adaptive filling.
  2010-03-01 13:49 [PATCH 1/2] org-babel-oz: Fix line-endings Dan Hackney
@ 2010-03-01 13:49 ` Dan Hackney
  2010-03-03 12:48   ` Carsten Dominik
                     ` (3 more replies)
  2010-03-01 15:31 ` [PATCH 1/2] org-babel-oz: Fix line-endings Eric Schulte
  1 sibling, 4 replies; 14+ messages in thread
From: Dan Hackney @ 2010-03-01 13:49 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Dan Hackney

For paragraph text, `org-adaptive-fill-function' did not handle the base case of
regular text which needed to be filled. This commit saves a buffer-local value
of `adaptive-fill-regexp' and uses it if none of the org-specific regexps match.
This allows email-style ">" comments to be filled correctly.

Signed-off-by: Dan Hackney <dan@haxney.org>
---
 lisp/org.el |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 8ba782a..073061e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17289,6 +17289,12 @@ which make use of the date at the cursor."
 		       t t))
     (org-move-to-column column)))
 
+(defvar org-adaptive-fill-regexp-backup adaptive-fill-regexp
+  "Variable to store copy of `adaptive-fill-regexp'.
+Since `adaptive-fill-regexp' is set to never match, we need to
+store a backup of its value before entering `org-mode' so that
+the functionality can be provided as a fall-back.")
+
 (defun org-set-autofill-regexps ()
   (interactive)
   ;; In the paragraph separator we include headlines, because filling
@@ -17324,8 +17330,11 @@ which make use of the date at the cursor."
   ;; and fixed-width regions are not wrapped.  That function will pass
   ;; through to `fill-paragraph' when appropriate.
   (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
-  ; Adaptive filling: To get full control, first make sure that
+  ;; Adaptive filling: To get full control, first make sure that
   ;; `adaptive-fill-regexp' never matches.  Then install our own matcher.
+  (unless (local-variable-p 'adaptive-fill-regexp)
+    (org-set-local 'org-adaptive-fill-regexp-backup
+                   adaptive-fill-regexp))
   (org-set-local 'adaptive-fill-regexp "\000")
   (org-set-local 'adaptive-fill-function
 		 'org-adaptive-fill-function)
@@ -17354,8 +17363,11 @@ which make use of the date at the cursor."
   "Return a fill prefix for org-mode files.
 In particular, this makes sure hanging paragraphs for hand-formatted lists
 work correctly."
-  (cond ((looking-at "#[ \t]+")
-	 (match-string 0))
+  (cond
+   ;; Comment line
+   ((looking-at "#[ \t]+")
+    (match-string-no-properties 0))
+   ;; Description list
 	((looking-at "[ \t]*\\([-*+] .*? :: \\)")
 	 (save-excursion
 	   (if (> (match-end 1) (+ (match-beginning 1)
@@ -17363,11 +17375,14 @@ work correctly."
 	       (goto-char (+ (match-beginning 1) 5))
 	     (goto-char (match-end 0)))
 	   (make-string (current-column) ?\ )))
-	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)?")
+    ;; Ordered or unordered list
+	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)")
 	 (save-excursion
 	   (goto-char (match-end 0))
 	   (make-string (current-column) ?\ )))
-	(t nil)))
+    ;; Other text
+    ((looking-at org-adaptive-fill-regexp-backup)
+     (match-string-no-properties 0))))
 
 ;;; Other stuff.
 
-- 
1.6.3.3

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

* Re: [PATCH 1/2] org-babel-oz: Fix line-endings.
  2010-03-01 13:49 [PATCH 1/2] org-babel-oz: Fix line-endings Dan Hackney
  2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
@ 2010-03-01 15:31 ` Eric Schulte
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Schulte @ 2010-03-01 15:31 UTC (permalink / raw)
  To: Dan Hackney; +Cc: emacs-orgmode

Fixed, thanks

Dan Hackney <dan@haxney.org> writes:

> Switch from Windows to Unix line-endings.
>
> Signed-off-by: Dan Hackney <dan@haxney.org>
> ---
>  contrib/babel/lisp/langs/org-babel-oz.el |  618 +++++++++++++++---------------
>  1 files changed, 309 insertions(+), 309 deletions(-)
>
> diff --git a/contrib/babel/lisp/langs/org-babel-oz.el b/contrib/babel/lisp/langs/org-babel-oz.el
> index 31b3bff..e81787b 100644
> --- a/contrib/babel/lisp/langs/org-babel-oz.el
> +++ b/contrib/babel/lisp/langs/org-babel-oz.el
> @@ -1,309 +1,309 @@
> -;;; org-babel-oz.el --- org-babel functions for Oz evaluation
> -
> -;; Copyright (C) 2009 Torsten Anders and Eric Schulte 
> -
> -;; Author: Torsten Anders and Eric Schulte 
> -;; Keywords: literate programming, reproducible research
> -;; Homepage: http://orgmode.org
> -;; Version: 0.01
> -
> -;;; License:
> -
> -;; This program 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, or (at your option)
> -;; any later version.
> -;;
> -;; This program 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; see the file COPYING.  If not, write to the
> -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> -;; Boston, MA 02110-1301, USA.
> -
> -;;; Commentary:
> -
> -;; Org-Babel support for evaluating Oz source code. 
> -;;
> -;; Oz code is always send to the Oz Programming Environment (OPI), the
> -;; Emacs mode and compiler interface for Oz programs. Therefore, only
> -;; session mode is supported. In practice, non-session code blocks are
> -;; handled equally well by the session mode. However, only a single
> -;; session is supported. Consequently, the :session header argument is
> -;; ignored.
> -;;
> -;; The Org-babel header argument :results is interpreted as
> -;; follows. :results output requires the respective code block to be
> -;; an Oz statement and :results value requires an Oz
> -;; expression. Currently, results are only supported for expressions
> -;; (i.e. the result of :results output is always nil).
> -;;
> -;; Expression evaluation happens synchronously. Therefore there is an
> -;; additional header argument :wait-time <number>, which specifies the
> -;; maximum time to wait for the result of a given expression. nil
> -;; means to wait as long as it takes to get a result (potentially wait
> -;; forever).
> -;;
> -;; NOTE: Currently the copyright of this file may not be in a state to
> -;;       permit inclusion as core software into Emacs or Org-mode.
> -
> -;;; Requirements:
> -
> -;; - Mozart Programming System, the implementation of the Oz
> -;;   programming language (http://www.mozart-oz.org/), which includes
> -;;   the major mode mozart for editing Oz programs.
> -;;
> -;; - StartOzServer.oz which is located in the contrib/scripts
> -;;   directory of the Org-mode repository
> -
> -;;; TODO:
> -
> -;; - Decide: set communication to \\switch -threadedqueries?
> -;;
> -;; - Only start Oz compiler when required, e.g., load Org-babel only when needed?
> -;;
> -;; - Avoid synchronous evaluation to avoid blocking Emacs (complex
> -;;   Strasheela programs can take long to find a result..). In order
> -;;   to cleanly map code blocks to their associated results (which can
> -;;   arrive then in any order) I could use IDs
> -;;   (e.g. integers). However, how do I do concurrency in Emacs Lisp,
> -;;   and how can I define org-babel-execute:oz concurrently.
> -;; 
> -;; - Expressions are rarely used in Oz at the top-level, and using
> -;;   them in documentation and Literate Programs will cause
> -;;   confusion. Idea: hide expression from reader and instead show
> -;;   them statement (e.g., MIDI output statement) and then include
> -;;   result in Org file. Implementation: for expressions (:results
> -;;   value) support an additional header argument that takes arbitrary
> -;;   Oz code. This code is not seen by the reader, but will be used
> -;;   for the actual expression at the end.  Alternative: feed all
> -;;   relevant code as statement (:results output), then add expression
> -;;   as extra code block which outputs, e.g., file name (so the file
> -;;   name must be accessible by global var), but the code of this
> -;;   extra codeblock is not seen.  Hm, in that case it might be even
> -;;   more easy to manually add this link to the Org file.
> -;;
> -
> -
> -(require 'org-babel)
> -;;; major mode for editing Oz programs
> -(require 'mozart)
> -
> -;; Add Oz to the list of supported languages.  Org-babel will match
> -;; the string below against the declared language of the source-code
> -;; block.
> -(org-babel-add-interpreter "oz")
> -
> -;; specify the name and file extension for Oz
> -(add-to-list 'org-babel-tangle-langs '("oz" "oz" nil nil))
> -
> -;;
> -;; Interface to communicate with Oz.
> -;; (1) For statements without any results: oz-send-string 
> -;; (2) For expressions with a single result: oz-send-string-expression
> -;;     (defined in org-babel-oz-ResultsValue.el)
> -;; 
> -
> -;; oz-send-string-expression implements an additional very direct
> -;; communication between Org-babel and the Oz compiler. Communication
> -;; with the Oz server works already without this code via the function
> -;; oz-send-string from mozart.el.in, but this function does not get
> -;; back any results from Oz to Emacs. The following code creates a
> -;; socket for sending code to the OPI compiler and results are
> -;; returned by the same socket. On the Oz side, a socket is opened and
> -;; conected to the compiler of the OPI (via oz-send-string). On the
> -;; Emacs side, a connection to this socket is created for feeding code
> -;; and receiving results. This additional communication channel to the
> -;; OPI compiler ensures that results are returned cleanly (e.g., only
> -;; the result of the sent code is returned, no parsing or any
> -;; processing of *Oz Emulator* is required).
> -;;
> -;; There is no buffer, nor sentinel involved. Oz code is send
> -;; directly, and results from Oz are send back, but Emacs Lisp
> -;; requires a filter function for processing results.
> -
> -(defvar org-babel-oz-server-dir
> -  (file-name-as-directory
> -   (expand-file-name
> -    "scripts"
> -    (file-name-as-directory
> -     (expand-file-name
> -      "../../.."
> -      (file-name-directory (or load-file-name buffer-file-name))))))
> -  "Path to the contrib/scripts directory in which
> -StartOzServer.oz is located.")
> -
> -(defvar org-babel-oz-port 6001		
> -  "Port for communicating with Oz compiler.")
> -(defvar org-babel-oz-OPI-socket nil
> -  "Socket for communicating with OPI.")
> -
> -(defvar org-babel-oz-collected-result nil
> -  "Aux var to hand result from org-babel-oz-filter to oz-send-string-expression.")
> -(defun org-babel-oz-filter (proc string)
> -  "Processes output from socket org-babel-oz-OPI-socket."
> -;;   (setq org-babel-oz-collected-results (cons string org-babel-oz-collected-results))
> -  (setq org-babel-oz-collected-result string)
> -  )
> -
> -
> -(defun org-babel-oz-create-socket ()
> -  (message "Create OPI socket for evaluating expressions")
> -  ;; Start Oz directly 
> -  (run-oz)
> -  ;; Create socket on Oz side (after Oz was started).
> -  (oz-send-string (concat "\\insert '" org-babel-oz-server-dir "StartOzServer.oz'"))
> -  ;; Wait until socket is created before connecting to it.
> -  ;; Quick hack: wait 3 sec
> -  ;; 
> -  ;; extending time to 30 secs does not help when starting Emacs for
> -  ;; the first time (and computer does nothing else)
> -  (sit-for 3)
> -  ;; connect to OPI socket
> -  (setq org-babel-oz-OPI-socket  
> -	;; Creates a socket. I/O interface of Emacs sockets as for processes.
> -	(open-network-stream "*Org-babel-OPI-socket*" nil "localhost" org-babel-oz-port))
> -  ;; install filter
> -  (set-process-filter org-babel-oz-OPI-socket #'org-babel-oz-filter)
> -)
> -
> -;; communication with org-babel-oz-OPI-socket is asynchronous, but
> -;; oz-send-string-expression turns is into synchronous...
> -(defun oz-send-string-expression (string &optional wait-time)
> -  "Similar to oz-send-string, oz-send-string-expression sends a string to the OPI compiler. However, string must be expression and this function returns the result of the expression (as string). oz-send-string-expression is synchronous, wait-time allows to specify a maximum wait time. After wait-time is over with no result, the function returns nil."
> -  (if (not org-babel-oz-OPI-socket) 
> -      (org-babel-oz-create-socket))
> -  (let ((polling-delay 0.1)
> -	result)
> -    (process-send-string org-babel-oz-OPI-socket string)
> -    ;; wait for result
> -    (if wait-time
> -	(let ((waited 0))
> -	  (unwind-protect
> -	      (progn
> -		(while 
> -		    ;; stop loop if org-babel-oz-collected-result \= nil or waiting time is over
> -		    (not (or (not (equal org-babel-oz-collected-result nil))
> -			     (> waited wait-time)))
> -		  (progn 
> -		    (sit-for polling-delay)
> -;; 		    (message "org-babel-oz: next polling iteration")
> -		    (setq waited (+ waited polling-delay))))
> -;; 		(message "org-babel-oz: waiting over, got result or waiting timed out")
> -;; 		(message (format "wait-time: %s, waited: %s" wait-time waited))
> -		(setq result org-babel-oz-collected-result)
> -		(setq org-babel-oz-collected-result nil))))
> -      (unwind-protect
> -	  (progn
> -	    (while (equal org-babel-oz-collected-result nil)
> -	      (sit-for polling-delay))
> -	    (setq result org-babel-oz-collected-result)
> -	    (setq org-babel-oz-collected-result nil))))
> -    result))
> -
> -
> -(defun org-babel-execute:oz (body params)
> -  "Execute a block of Oz code with org-babel.  This function is
> -called by `org-babel-execute-src-block' via multiple-value-bind."
> -  (let* ((processed-params (org-babel-process-params params))
> -;; 	(session (org-babel-ruby-initiate-session (first processed-params)))
> -	(vars (second processed-params))
> -;; 	(result-params (third processed-params))
> -	(result-type (fourth processed-params))
> -	(full-body (if vars
> -		       ;; only add var declarations if any variables are there
> -		     (concat
> -		      ;; prepend code to define all arguments passed to the code block
> -		      "local\n"
> -		      (mapconcat
> -		       (lambda (pair)
> -			 (format "%s=%s"
> -				 (car pair)
> -				 (org-babel-oz-var-to-oz (cdr pair))))
> -		       vars "\n") "\n" 
> -		       "in\n"
> -		       body 
> -		       "end\n")
> -		     body))
> -	(wait-time (plist-get params :wait-time))
> -        ;; set the session if the session variable is non-nil
> -;; 	(session-buffer (org-babel-oz-initiate-session session))
> -;; 	(session (org-babel-prep-session:oz session params))
> -	)
> -    ;; actually execute the source-code block 
> -     (case result-type
> -       (output
> -	(progn 
> -	  (message "Org-babel: executing Oz statement")
> -	  (oz-send-string full-body)))
> -       (value
> -	(progn 
> -	  (message "Org-babel: executing Oz expression")
> -	  (oz-send-string-expression full-body (if wait-time
> -						   wait-time
> -						 1)))))
> -    ))
> -
> -;; This function should be used to assign any variables in params in
> -;; the context of the session environment.
> -(defun org-babel-prep-session:oz (session params)
> -  "Prepare SESSION according to the header arguments specified in PARAMS."
> -  (error "org-babel-prep-session:oz unimplemented"))
> -;; TODO: testing... (copied from org-babel-haskell.el)
> -;; (defun org-babel-prep-session:oz (session params)
> -;;   "Prepare SESSION according to the header arguments specified in PARAMS."
> -;;   (save-window-excursion
> -;;     (org-babel-oz-initiate-session session)
> -;;     (let* ((vars (org-babel-ref-variables params))
> -;;            (var-lines (mapconcat ;; define any variables
> -;;                        (lambda (pair)
> -;;                          (format "%s=%s"
> -;;                                  (car pair)
> -;;                                  (org-babel-ruby-var-to-ruby (cdr pair))))
> -;;                        vars "\n"))
> -;;            (vars-file (concat (make-temp-file "org-babel-oz-vars") ".oz")))
> -;;       (when vars
> -;;         (with-temp-buffer
> -;;           (insert var-lines) (write-file vars-file)
> -;;           (oz-mode) 
> -;; ;; 	  (inferior-oz-load-file) ; ??
> -;; 	  ))
> -;;       (current-buffer))))
> -;;
> -
> -
> -;; TODO: testing... (simplified version of def in org-babel-prep-session:ocaml)
> -;;
> -;; BUG: does not work yet. Error: ad-Orig-error: buffer none doesn't exist or has no process 
> -;; UNUSED DEF
> -(defun org-babel-oz-initiate-session (&optional session)
> -  "If there is not a current inferior-process-buffer in SESSION
> -then create.  Return the initialized session."
> -  (unless (string= session "none")
> -    ;; TODO: make it possible to have multiple sessions
> -    (save-window-excursion
> -      ;; (run-oz)
> -      (get-buffer oz-compiler-buffer))))
> -
> -(defun org-babel-oz-var-to-oz (var)
> -  "Convert an elisp var into a string of Oz source code
> -specifying a var of the same value."
> -  (if (listp var)
> -;;       (concat "[" (mapconcat #'org-babel-oz-var-to-oz var ", ") "]")
> -      (eval var) 
> -    (format "%s" var) ; don't preserve string quotes. 
> -;;     (format "%s" var)
> -    ))
> -
> -;; TODO: 
> -(defun org-babel-oz-table-or-string (results)
> -  "If the results look like a table, then convert them into an
> -Emacs-lisp table, otherwise return the results as a string."
> -  (error "org-babel-oz-table-or-string unimplemented"))
> -
> -
> -(provide 'org-babel-oz)
> -;;; org-babel-oz.el ends here
> +;;; org-babel-oz.el --- org-babel functions for Oz evaluation
> +
> +;; Copyright (C) 2009 Torsten Anders and Eric Schulte
> +
> +;; Author: Torsten Anders and Eric Schulte
> +;; Keywords: literate programming, reproducible research
> +;; Homepage: http://orgmode.org
> +;; Version: 0.01
> +
> +;;; License:
> +
> +;; This program 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, or (at your option)
> +;; any later version.
> +;;
> +;; This program 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; see the file COPYING.  If not, write to the
> +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> +;; Boston, MA 02110-1301, USA.
> +
> +;;; Commentary:
> +
> +;; Org-Babel support for evaluating Oz source code.
> +;;
> +;; Oz code is always send to the Oz Programming Environment (OPI), the
> +;; Emacs mode and compiler interface for Oz programs. Therefore, only
> +;; session mode is supported. In practice, non-session code blocks are
> +;; handled equally well by the session mode. However, only a single
> +;; session is supported. Consequently, the :session header argument is
> +;; ignored.
> +;;
> +;; The Org-babel header argument :results is interpreted as
> +;; follows. :results output requires the respective code block to be
> +;; an Oz statement and :results value requires an Oz
> +;; expression. Currently, results are only supported for expressions
> +;; (i.e. the result of :results output is always nil).
> +;;
> +;; Expression evaluation happens synchronously. Therefore there is an
> +;; additional header argument :wait-time <number>, which specifies the
> +;; maximum time to wait for the result of a given expression. nil
> +;; means to wait as long as it takes to get a result (potentially wait
> +;; forever).
> +;;
> +;; NOTE: Currently the copyright of this file may not be in a state to
> +;;       permit inclusion as core software into Emacs or Org-mode.
> +
> +;;; Requirements:
> +
> +;; - Mozart Programming System, the implementation of the Oz
> +;;   programming language (http://www.mozart-oz.org/), which includes
> +;;   the major mode mozart for editing Oz programs.
> +;;
> +;; - StartOzServer.oz which is located in the contrib/scripts
> +;;   directory of the Org-mode repository
> +
> +;;; TODO:
> +
> +;; - Decide: set communication to \\switch -threadedqueries?
> +;;
> +;; - Only start Oz compiler when required, e.g., load Org-babel only when needed?
> +;;
> +;; - Avoid synchronous evaluation to avoid blocking Emacs (complex
> +;;   Strasheela programs can take long to find a result..). In order
> +;;   to cleanly map code blocks to their associated results (which can
> +;;   arrive then in any order) I could use IDs
> +;;   (e.g. integers). However, how do I do concurrency in Emacs Lisp,
> +;;   and how can I define org-babel-execute:oz concurrently.
> +;;
> +;; - Expressions are rarely used in Oz at the top-level, and using
> +;;   them in documentation and Literate Programs will cause
> +;;   confusion. Idea: hide expression from reader and instead show
> +;;   them statement (e.g., MIDI output statement) and then include
> +;;   result in Org file. Implementation: for expressions (:results
> +;;   value) support an additional header argument that takes arbitrary
> +;;   Oz code. This code is not seen by the reader, but will be used
> +;;   for the actual expression at the end.  Alternative: feed all
> +;;   relevant code as statement (:results output), then add expression
> +;;   as extra code block which outputs, e.g., file name (so the file
> +;;   name must be accessible by global var), but the code of this
> +;;   extra codeblock is not seen.  Hm, in that case it might be even
> +;;   more easy to manually add this link to the Org file.
> +;;
> +
> +
> +(require 'org-babel)
> +;;; major mode for editing Oz programs
> +(require 'mozart)
> +
> +;; Add Oz to the list of supported languages.  Org-babel will match
> +;; the string below against the declared language of the source-code
> +;; block.
> +(org-babel-add-interpreter "oz")
> +
> +;; specify the name and file extension for Oz
> +(add-to-list 'org-babel-tangle-langs '("oz" "oz" nil nil))
> +
> +;;
> +;; Interface to communicate with Oz.
> +;; (1) For statements without any results: oz-send-string
> +;; (2) For expressions with a single result: oz-send-string-expression
> +;;     (defined in org-babel-oz-ResultsValue.el)
> +;;
> +
> +;; oz-send-string-expression implements an additional very direct
> +;; communication between Org-babel and the Oz compiler. Communication
> +;; with the Oz server works already without this code via the function
> +;; oz-send-string from mozart.el.in, but this function does not get
> +;; back any results from Oz to Emacs. The following code creates a
> +;; socket for sending code to the OPI compiler and results are
> +;; returned by the same socket. On the Oz side, a socket is opened and
> +;; conected to the compiler of the OPI (via oz-send-string). On the
> +;; Emacs side, a connection to this socket is created for feeding code
> +;; and receiving results. This additional communication channel to the
> +;; OPI compiler ensures that results are returned cleanly (e.g., only
> +;; the result of the sent code is returned, no parsing or any
> +;; processing of *Oz Emulator* is required).
> +;;
> +;; There is no buffer, nor sentinel involved. Oz code is send
> +;; directly, and results from Oz are send back, but Emacs Lisp
> +;; requires a filter function for processing results.
> +
> +(defvar org-babel-oz-server-dir
> +  (file-name-as-directory
> +   (expand-file-name
> +    "scripts"
> +    (file-name-as-directory
> +     (expand-file-name
> +      "../../.."
> +      (file-name-directory (or load-file-name buffer-file-name))))))
> +  "Path to the contrib/scripts directory in which
> +StartOzServer.oz is located.")
> +
> +(defvar org-babel-oz-port 6001
> +  "Port for communicating with Oz compiler.")
> +(defvar org-babel-oz-OPI-socket nil
> +  "Socket for communicating with OPI.")
> +
> +(defvar org-babel-oz-collected-result nil
> +  "Aux var to hand result from org-babel-oz-filter to oz-send-string-expression.")
> +(defun org-babel-oz-filter (proc string)
> +  "Processes output from socket org-babel-oz-OPI-socket."
> +;;   (setq org-babel-oz-collected-results (cons string org-babel-oz-collected-results))
> +  (setq org-babel-oz-collected-result string)
> +  )
> +
> +
> +(defun org-babel-oz-create-socket ()
> +  (message "Create OPI socket for evaluating expressions")
> +  ;; Start Oz directly
> +  (run-oz)
> +  ;; Create socket on Oz side (after Oz was started).
> +  (oz-send-string (concat "\\insert '" org-babel-oz-server-dir "StartOzServer.oz'"))
> +  ;; Wait until socket is created before connecting to it.
> +  ;; Quick hack: wait 3 sec
> +  ;;
> +  ;; extending time to 30 secs does not help when starting Emacs for
> +  ;; the first time (and computer does nothing else)
> +  (sit-for 3)
> +  ;; connect to OPI socket
> +  (setq org-babel-oz-OPI-socket
> +	;; Creates a socket. I/O interface of Emacs sockets as for processes.
> +	(open-network-stream "*Org-babel-OPI-socket*" nil "localhost" org-babel-oz-port))
> +  ;; install filter
> +  (set-process-filter org-babel-oz-OPI-socket #'org-babel-oz-filter)
> +)
> +
> +;; communication with org-babel-oz-OPI-socket is asynchronous, but
> +;; oz-send-string-expression turns is into synchronous...
> +(defun oz-send-string-expression (string &optional wait-time)
> +  "Similar to oz-send-string, oz-send-string-expression sends a string to the OPI compiler. However, string must be expression and this function returns the result of the expression (as string). oz-send-string-expression is synchronous, wait-time allows to specify a maximum wait time. After wait-time is over with no result, the function returns nil."
> +  (if (not org-babel-oz-OPI-socket)
> +      (org-babel-oz-create-socket))
> +  (let ((polling-delay 0.1)
> +	result)
> +    (process-send-string org-babel-oz-OPI-socket string)
> +    ;; wait for result
> +    (if wait-time
> +	(let ((waited 0))
> +	  (unwind-protect
> +	      (progn
> +		(while
> +		    ;; stop loop if org-babel-oz-collected-result \= nil or waiting time is over
> +		    (not (or (not (equal org-babel-oz-collected-result nil))
> +			     (> waited wait-time)))
> +		  (progn
> +		    (sit-for polling-delay)
> +;; 		    (message "org-babel-oz: next polling iteration")
> +		    (setq waited (+ waited polling-delay))))
> +;; 		(message "org-babel-oz: waiting over, got result or waiting timed out")
> +;; 		(message (format "wait-time: %s, waited: %s" wait-time waited))
> +		(setq result org-babel-oz-collected-result)
> +		(setq org-babel-oz-collected-result nil))))
> +      (unwind-protect
> +	  (progn
> +	    (while (equal org-babel-oz-collected-result nil)
> +	      (sit-for polling-delay))
> +	    (setq result org-babel-oz-collected-result)
> +	    (setq org-babel-oz-collected-result nil))))
> +    result))
> +
> +
> +(defun org-babel-execute:oz (body params)
> +  "Execute a block of Oz code with org-babel.  This function is
> +called by `org-babel-execute-src-block' via multiple-value-bind."
> +  (let* ((processed-params (org-babel-process-params params))
> +;; 	(session (org-babel-ruby-initiate-session (first processed-params)))
> +	(vars (second processed-params))
> +;; 	(result-params (third processed-params))
> +	(result-type (fourth processed-params))
> +	(full-body (if vars
> +		       ;; only add var declarations if any variables are there
> +		     (concat
> +		      ;; prepend code to define all arguments passed to the code block
> +		      "local\n"
> +		      (mapconcat
> +		       (lambda (pair)
> +			 (format "%s=%s"
> +				 (car pair)
> +				 (org-babel-oz-var-to-oz (cdr pair))))
> +		       vars "\n") "\n"
> +		       "in\n"
> +		       body
> +		       "end\n")
> +		     body))
> +	(wait-time (plist-get params :wait-time))
> +        ;; set the session if the session variable is non-nil
> +;; 	(session-buffer (org-babel-oz-initiate-session session))
> +;; 	(session (org-babel-prep-session:oz session params))
> +	)
> +    ;; actually execute the source-code block
> +     (case result-type
> +       (output
> +	(progn
> +	  (message "Org-babel: executing Oz statement")
> +	  (oz-send-string full-body)))
> +       (value
> +	(progn
> +	  (message "Org-babel: executing Oz expression")
> +	  (oz-send-string-expression full-body (if wait-time
> +						   wait-time
> +						 1)))))
> +    ))
> +
> +;; This function should be used to assign any variables in params in
> +;; the context of the session environment.
> +(defun org-babel-prep-session:oz (session params)
> +  "Prepare SESSION according to the header arguments specified in PARAMS."
> +  (error "org-babel-prep-session:oz unimplemented"))
> +;; TODO: testing... (copied from org-babel-haskell.el)
> +;; (defun org-babel-prep-session:oz (session params)
> +;;   "Prepare SESSION according to the header arguments specified in PARAMS."
> +;;   (save-window-excursion
> +;;     (org-babel-oz-initiate-session session)
> +;;     (let* ((vars (org-babel-ref-variables params))
> +;;            (var-lines (mapconcat ;; define any variables
> +;;                        (lambda (pair)
> +;;                          (format "%s=%s"
> +;;                                  (car pair)
> +;;                                  (org-babel-ruby-var-to-ruby (cdr pair))))
> +;;                        vars "\n"))
> +;;            (vars-file (concat (make-temp-file "org-babel-oz-vars") ".oz")))
> +;;       (when vars
> +;;         (with-temp-buffer
> +;;           (insert var-lines) (write-file vars-file)
> +;;           (oz-mode)
> +;; ;; 	  (inferior-oz-load-file) ; ??
> +;; 	  ))
> +;;       (current-buffer))))
> +;;
> +
> +
> +;; TODO: testing... (simplified version of def in org-babel-prep-session:ocaml)
> +;;
> +;; BUG: does not work yet. Error: ad-Orig-error: buffer none doesn't exist or has no process
> +;; UNUSED DEF
> +(defun org-babel-oz-initiate-session (&optional session)
> +  "If there is not a current inferior-process-buffer in SESSION
> +then create.  Return the initialized session."
> +  (unless (string= session "none")
> +    ;; TODO: make it possible to have multiple sessions
> +    (save-window-excursion
> +      ;; (run-oz)
> +      (get-buffer oz-compiler-buffer))))
> +
> +(defun org-babel-oz-var-to-oz (var)
> +  "Convert an elisp var into a string of Oz source code
> +specifying a var of the same value."
> +  (if (listp var)
> +;;       (concat "[" (mapconcat #'org-babel-oz-var-to-oz var ", ") "]")
> +      (eval var)
> +    (format "%s" var) ; don't preserve string quotes.
> +;;     (format "%s" var)
> +    ))
> +
> +;; TODO:
> +(defun org-babel-oz-table-or-string (results)
> +  "If the results look like a table, then convert them into an
> +Emacs-lisp table, otherwise return the results as a string."
> +  (error "org-babel-oz-table-or-string unimplemented"))
> +
> +
> +(provide 'org-babel-oz)
> +;;; org-babel-oz.el ends here

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
@ 2010-03-03 12:48   ` Carsten Dominik
  2010-03-03 20:06     ` Austin Frank
  2010-03-04  1:17   ` Samuel Wales
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-03-03 12:48 UTC (permalink / raw)
  To: Dan Hackney; +Cc: emacs-orgmode

Hi,

can I ask a few volunteers to try out this patch?  I am not sure if I  
can completely oversee if this will not have adverse effects.

Thanks Dan!

- Carsten

On Mar 1, 2010, at 2:49 PM, Dan Hackney wrote:

> For paragraph text, `org-adaptive-fill-function' did not handle the  
> base case of
> regular text which needed to be filled. This commit saves a buffer- 
> local value
> of `adaptive-fill-regexp' and uses it if none of the org-specific  
> regexps match.
> This allows email-style ">" comments to be filled correctly.
>
> Signed-off-by: Dan Hackney <dan@haxney.org>
> ---
> lisp/org.el |   25 ++++++++++++++++++++-----
> 1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 8ba782a..073061e 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -17289,6 +17289,12 @@ which make use of the date at the cursor."
> 		       t t))
>     (org-move-to-column column)))
>
> +(defvar org-adaptive-fill-regexp-backup adaptive-fill-regexp
> +  "Variable to store copy of `adaptive-fill-regexp'.
> +Since `adaptive-fill-regexp' is set to never match, we need to
> +store a backup of its value before entering `org-mode' so that
> +the functionality can be provided as a fall-back.")
> +
> (defun org-set-autofill-regexps ()
>   (interactive)
>   ;; In the paragraph separator we include headlines, because filling
> @@ -17324,8 +17330,11 @@ which make use of the date at the cursor."
>   ;; and fixed-width regions are not wrapped.  That function will pass
>   ;; through to `fill-paragraph' when appropriate.
>   (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
> -  ; Adaptive filling: To get full control, first make sure that
> +  ;; Adaptive filling: To get full control, first make sure that
>   ;; `adaptive-fill-regexp' never matches.  Then install our own  
> matcher.
> +  (unless (local-variable-p 'adaptive-fill-regexp)
> +    (org-set-local 'org-adaptive-fill-regexp-backup
> +                   adaptive-fill-regexp))
>   (org-set-local 'adaptive-fill-regexp "\000")
>   (org-set-local 'adaptive-fill-function
> 		 'org-adaptive-fill-function)
> @@ -17354,8 +17363,11 @@ which make use of the date at the cursor."
>   "Return a fill prefix for org-mode files.
> In particular, this makes sure hanging paragraphs for hand-formatted  
> lists
> work correctly."
> -  (cond ((looking-at "#[ \t]+")
> -	 (match-string 0))
> +  (cond
> +   ;; Comment line
> +   ((looking-at "#[ \t]+")
> +    (match-string-no-properties 0))
> +   ;; Description list
> 	((looking-at "[ \t]*\\([-*+] .*? :: \\)")
> 	 (save-excursion
> 	   (if (> (match-end 1) (+ (match-beginning 1)
> @@ -17363,11 +17375,14 @@ work correctly."
> 	       (goto-char (+ (match-beginning 1) 5))
> 	     (goto-char (match-end 0)))
> 	   (make-string (current-column) ?\ )))
> -	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)?")
> +    ;; Ordered or unordered list
> +	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)")
> 	 (save-excursion
> 	   (goto-char (match-end 0))
> 	   (make-string (current-column) ?\ )))
> -	(t nil)))
> +    ;; Other text
> +    ((looking-at org-adaptive-fill-regexp-backup)
> +     (match-string-no-properties 0))))
>
> ;;; Other stuff.
>
> -- 
> 1.6.3.3
>
>
>
> _______________________________________________
> 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

- Carsten

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-03 12:48   ` Carsten Dominik
@ 2010-03-03 20:06     ` Austin Frank
  0 siblings, 0 replies; 14+ messages in thread
From: Austin Frank @ 2010-03-03 20:06 UTC (permalink / raw)
  To: emacs-orgmode


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

On Wed, Mar 03 2010, Carsten Dominik wrote:

> Hi,
>
> can I ask a few volunteers to try out this patch?  I am not sure if I
> can completely oversee if this will not have adverse effects.
>
> Thanks Dan!

I've applied this patch and will report back.  I've noticed that with
orgstruct++-mode enabled for message composition, I lose wrapping of
paragraphs with multiple prefixed quote indicators (e.g., "> >").  I'm
eager to see if this addresses that.

For anyone wondering how to apply a patch from an email in gnus, here's
what I just figured out:

 1. Save the entire message using `gnus-uu-decode-save' (bound to `X o'
    on my system).  I saved it to ~/repos/org-mode.remote/adaptive.patch
 2. cd to the org-mode repository
 3. apply the patch using git am:

    git am < adaptive.patch

I was pleased that this was so was so easy to do once I figured it out.
I honestly didn't expect 'git am' to work with a message saved from
gnus, since the man page talks about mbox files and so on.  But it did
work, and I figured I'd pass it on.

Have a good one,
/au

-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

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

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
  2010-03-03 12:48   ` Carsten Dominik
@ 2010-03-04  1:17   ` Samuel Wales
  2010-03-04  1:25     ` Daniel Hackney
  2010-03-11 17:13   ` Carsten Dominik
  2010-03-15 15:48   ` Carsten Dominik
  3 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2010-03-04  1:17 UTC (permalink / raw)
  To: Dan Hackney; +Cc: emacs-orgmode

How will the new value of a non-org variable affect filladapt.el?

On 2010-03-01, Dan Hackney <dan@haxney.org> wrote:
> For paragraph text, `org-adaptive-fill-function' did not handle the base
> case of
> regular text which needed to be filled. This commit saves a buffer-local
> value
> of `adaptive-fill-regexp' and uses it if none of the org-specific regexps
> match.
> This allows email-style ">" comments to be filled correctly.
>
> Signed-off-by: Dan Hackney <dan@haxney.org>
> ---
>  lisp/org.el |   25 ++++++++++++++++++++-----
>  1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 8ba782a..073061e 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -17289,6 +17289,12 @@ which make use of the date at the cursor."
>  		       t t))
>      (org-move-to-column column)))
>
> +(defvar org-adaptive-fill-regexp-backup adaptive-fill-regexp
> +  "Variable to store copy of `adaptive-fill-regexp'.
> +Since `adaptive-fill-regexp' is set to never match, we need to
> +store a backup of its value before entering `org-mode' so that
> +the functionality can be provided as a fall-back.")
> +
>  (defun org-set-autofill-regexps ()
>    (interactive)
>    ;; In the paragraph separator we include headlines, because filling
> @@ -17324,8 +17330,11 @@ which make use of the date at the cursor."
>    ;; and fixed-width regions are not wrapped.  That function will pass
>    ;; through to `fill-paragraph' when appropriate.
>    (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
> -  ; Adaptive filling: To get full control, first make sure that
> +  ;; Adaptive filling: To get full control, first make sure that
>    ;; `adaptive-fill-regexp' never matches.  Then install our own matcher.
> +  (unless (local-variable-p 'adaptive-fill-regexp)
> +    (org-set-local 'org-adaptive-fill-regexp-backup
> +                   adaptive-fill-regexp))
>    (org-set-local 'adaptive-fill-regexp "\000")
>    (org-set-local 'adaptive-fill-function
>  		 'org-adaptive-fill-function)
> @@ -17354,8 +17363,11 @@ which make use of the date at the cursor."
>    "Return a fill prefix for org-mode files.
>  In particular, this makes sure hanging paragraphs for hand-formatted lists
>  work correctly."
> -  (cond ((looking-at "#[ \t]+")
> -	 (match-string 0))
> +  (cond
> +   ;; Comment line
> +   ((looking-at "#[ \t]+")
> +    (match-string-no-properties 0))
> +   ;; Description list
>  	((looking-at "[ \t]*\\([-*+] .*? :: \\)")
>  	 (save-excursion
>  	   (if (> (match-end 1) (+ (match-beginning 1)
> @@ -17363,11 +17375,14 @@ work correctly."
>  	       (goto-char (+ (match-beginning 1) 5))
>  	     (goto-char (match-end 0)))
>  	   (make-string (current-column) ?\ )))
> -	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)?")
> +    ;; Ordered or unordered list
> +	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)")
>  	 (save-excursion
>  	   (goto-char (match-end 0))
>  	   (make-string (current-column) ?\ )))
> -	(t nil)))
> +    ;; Other text
> +    ((looking-at org-adaptive-fill-regexp-backup)
> +     (match-string-no-properties 0))))
>
>  ;;; Other stuff.
>
> --
> 1.6.3.3
>
>
>
> _______________________________________________
> 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
>


-- 
Q: How many CDC "scientists" does it take to change a lightbulb?
A: "You only think it's dark." [CDC has denied a deadly disease for 25 years]
==========
Retrovirus: http://www.wpinstitute.org/xmrv/index.html

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-04  1:17   ` Samuel Wales
@ 2010-03-04  1:25     ` Daniel Hackney
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Hackney @ 2010-03-04  1:25 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales <samologist@gmail.com> wrote:
> How will the new value of a non-org variable affect filladapt.el?

I don't use filladapt.el, so I can't be sure, but the change I made is
pretty non-invasive, so I doubt many problems would arise. I'm not quite
sure of what is being asked, however; what would filladapt.el do that
could be affected by this?

> On 2010-03-01, Dan Hackney <dan@haxney.org> wrote:
>> For paragraph text, `org-adaptive-fill-function' did not handle the
>> base case of regular text which needed to be filled. This commit
>> saves a buffer-local value of `adaptive-fill-regexp' and uses it if
>> none of the org-specific regexps match. This allows email-style ">"
>> comments to be filled correctly.

--
Daniel M. Hackney

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
  2010-03-03 12:48   ` Carsten Dominik
  2010-03-04  1:17   ` Samuel Wales
@ 2010-03-11 17:13   ` Carsten Dominik
  2010-03-12  2:55     ` Austin Frank
  2010-03-15 15:48   ` Carsten Dominik
  3 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-03-11 17:13 UTC (permalink / raw)
  To: Dan Hackney; +Cc: emacs-orgmode

Hi everyone,


I know that a few people have been using this patch.

How has it been working?

- Carsten

On Mar 1, 2010, at 2:49 PM, Dan Hackney wrote:

> For paragraph text, `org-adaptive-fill-function' did not handle the  
> base case of
> regular text which needed to be filled. This commit saves a buffer- 
> local value
> of `adaptive-fill-regexp' and uses it if none of the org-specific  
> regexps match.
> This allows email-style ">" comments to be filled correctly.
>
> Signed-off-by: Dan Hackney <dan@haxney.org>
> ---
> lisp/org.el |   25 ++++++++++++++++++++-----
> 1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 8ba782a..073061e 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -17289,6 +17289,12 @@ which make use of the date at the cursor."
> 		       t t))
>     (org-move-to-column column)))
>
> +(defvar org-adaptive-fill-regexp-backup adaptive-fill-regexp
> +  "Variable to store copy of `adaptive-fill-regexp'.
> +Since `adaptive-fill-regexp' is set to never match, we need to
> +store a backup of its value before entering `org-mode' so that
> +the functionality can be provided as a fall-back.")
> +
> (defun org-set-autofill-regexps ()
>   (interactive)
>   ;; In the paragraph separator we include headlines, because filling
> @@ -17324,8 +17330,11 @@ which make use of the date at the cursor."
>   ;; and fixed-width regions are not wrapped.  That function will pass
>   ;; through to `fill-paragraph' when appropriate.
>   (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
> -  ; Adaptive filling: To get full control, first make sure that
> +  ;; Adaptive filling: To get full control, first make sure that
>   ;; `adaptive-fill-regexp' never matches.  Then install our own  
> matcher.
> +  (unless (local-variable-p 'adaptive-fill-regexp)
> +    (org-set-local 'org-adaptive-fill-regexp-backup
> +                   adaptive-fill-regexp))
>   (org-set-local 'adaptive-fill-regexp "\000")
>   (org-set-local 'adaptive-fill-function
> 		 'org-adaptive-fill-function)
> @@ -17354,8 +17363,11 @@ which make use of the date at the cursor."
>   "Return a fill prefix for org-mode files.
> In particular, this makes sure hanging paragraphs for hand-formatted  
> lists
> work correctly."
> -  (cond ((looking-at "#[ \t]+")
> -	 (match-string 0))
> +  (cond
> +   ;; Comment line
> +   ((looking-at "#[ \t]+")
> +    (match-string-no-properties 0))
> +   ;; Description list
> 	((looking-at "[ \t]*\\([-*+] .*? :: \\)")
> 	 (save-excursion
> 	   (if (> (match-end 1) (+ (match-beginning 1)
> @@ -17363,11 +17375,14 @@ work correctly."
> 	       (goto-char (+ (match-beginning 1) 5))
> 	     (goto-char (match-end 0)))
> 	   (make-string (current-column) ?\ )))
> -	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)?")
> +    ;; Ordered or unordered list
> +	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)")
> 	 (save-excursion
> 	   (goto-char (match-end 0))
> 	   (make-string (current-column) ?\ )))
> -	(t nil)))
> +    ;; Other text
> +    ((looking-at org-adaptive-fill-regexp-backup)
> +     (match-string-no-properties 0))))
>
> ;;; Other stuff.
>
> -- 
> 1.6.3.3
>
>
>
> _______________________________________________
> 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

- Carsten

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-11 17:13   ` Carsten Dominik
@ 2010-03-12  2:55     ` Austin Frank
  2010-03-12  4:57       ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Austin Frank @ 2010-03-12  2:55 UTC (permalink / raw)
  To: emacs-orgmode


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

On Thu, Mar 11 2010, Carsten Dominik wrote:

> Hi everyone,
>
>
> I know that a few people have been using this patch.
>
> How has it been working?

Brilliant.  When composing messages in mml-mode with orgstruct++-mode
enabled, I now get mml-appropriate wrapping in non-orgish parts of the
message.  This mostly means that on message sections with more than one
level of quoting I get proper wrapping.

Thanks for the patch, and I'd be in favor of including it in core org.

Thanks,
/au

-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

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

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

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

* Re: Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-12  2:55     ` Austin Frank
@ 2010-03-12  4:57       ` Samuel Wales
  0 siblings, 0 replies; 14+ messages in thread
From: Samuel Wales @ 2010-03-12  4:57 UTC (permalink / raw)
  To: Austin Frank; +Cc: emacs-orgmode

Unable to test it now.

On 2010-03-11, Austin Frank <austin.frank@gmail.com> wrote:
> On Thu, Mar 11 2010, Carsten Dominik wrote:
>
>> Hi everyone,
>>
>>
>> I know that a few people have been using this patch.
>>
>> How has it been working?
>
> Brilliant.  When composing messages in mml-mode with orgstruct++-mode
> enabled, I now get mml-appropriate wrapping in non-orgish parts of the
> message.  This mostly means that on message sections with more than one
> level of quoting I get proper wrapping.
>
> Thanks for the patch, and I'd be in favor of including it in core org.
>
> Thanks,
> /au
>
> --
> Austin Frank
> http://aufrank.net
> GPG Public Key (D7398C2F): http://aufrank.net/personal.asc
>


-- 
Q: How many CDC "scientists" does it take to change a lightbulb?
A: "You only think it's dark." [CDC has denied a deadly disease for 25 years]
==========
Retrovirus: http://www.wpinstitute.org/xmrv/index.html

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
                     ` (2 preceding siblings ...)
  2010-03-11 17:13   ` Carsten Dominik
@ 2010-03-15 15:48   ` Carsten Dominik
  2010-03-15 19:04     ` Daniel Hackney
  2010-06-03 15:11     ` Daniel Hackney
  3 siblings, 2 replies; 14+ messages in thread
From: Carsten Dominik @ 2010-03-15 15:48 UTC (permalink / raw)
  To: Dan Hackney; +Cc: emacs-orgmode

Hi Dan,

I have applied your patch thanks.

This is a the limit of what I can take without you signing the FSF  
papers.  Would you consider signing them?

Thanks

- Carsten

On Mar 1, 2010, at 2:49 PM, Dan Hackney wrote:

> For paragraph text, `org-adaptive-fill-function' did not handle the  
> base case of
> regular text which needed to be filled. This commit saves a buffer- 
> local value
> of `adaptive-fill-regexp' and uses it if none of the org-specific  
> regexps match.
> This allows email-style ">" comments to be filled correctly.
>
> Signed-off-by: Dan Hackney <dan@haxney.org>
> ---
> lisp/org.el |   25 ++++++++++++++++++++-----
> 1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 8ba782a..073061e 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -17289,6 +17289,12 @@ which make use of the date at the cursor."
> 		       t t))
>     (org-move-to-column column)))
>
> +(defvar org-adaptive-fill-regexp-backup adaptive-fill-regexp
> +  "Variable to store copy of `adaptive-fill-regexp'.
> +Since `adaptive-fill-regexp' is set to never match, we need to
> +store a backup of its value before entering `org-mode' so that
> +the functionality can be provided as a fall-back.")
> +
> (defun org-set-autofill-regexps ()
>   (interactive)
>   ;; In the paragraph separator we include headlines, because filling
> @@ -17324,8 +17330,11 @@ which make use of the date at the cursor."
>   ;; and fixed-width regions are not wrapped.  That function will pass
>   ;; through to `fill-paragraph' when appropriate.
>   (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
> -  ; Adaptive filling: To get full control, first make sure that
> +  ;; Adaptive filling: To get full control, first make sure that
>   ;; `adaptive-fill-regexp' never matches.  Then install our own  
> matcher.
> +  (unless (local-variable-p 'adaptive-fill-regexp)
> +    (org-set-local 'org-adaptive-fill-regexp-backup
> +                   adaptive-fill-regexp))
>   (org-set-local 'adaptive-fill-regexp "\000")
>   (org-set-local 'adaptive-fill-function
> 		 'org-adaptive-fill-function)
> @@ -17354,8 +17363,11 @@ which make use of the date at the cursor."
>   "Return a fill prefix for org-mode files.
> In particular, this makes sure hanging paragraphs for hand-formatted  
> lists
> work correctly."
> -  (cond ((looking-at "#[ \t]+")
> -	 (match-string 0))
> +  (cond
> +   ;; Comment line
> +   ((looking-at "#[ \t]+")
> +    (match-string-no-properties 0))
> +   ;; Description list
> 	((looking-at "[ \t]*\\([-*+] .*? :: \\)")
> 	 (save-excursion
> 	   (if (> (match-end 1) (+ (match-beginning 1)
> @@ -17363,11 +17375,14 @@ work correctly."
> 	       (goto-char (+ (match-beginning 1) 5))
> 	     (goto-char (match-end 0)))
> 	   (make-string (current-column) ?\ )))
> -	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)?")
> +    ;; Ordered or unordered list
> +	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)")
> 	 (save-excursion
> 	   (goto-char (match-end 0))
> 	   (make-string (current-column) ?\ )))
> -	(t nil)))
> +    ;; Other text
> +    ((looking-at org-adaptive-fill-regexp-backup)
> +     (match-string-no-properties 0))))
>
> ;;; Other stuff.
>
> -- 
> 1.6.3.3
>
>
>
> _______________________________________________
> 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

- Carsten

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-15 15:48   ` Carsten Dominik
@ 2010-03-15 19:04     ` Daniel Hackney
  2010-03-15 19:16       ` Carsten Dominik
  2010-06-03 15:11     ` Daniel Hackney
  1 sibling, 1 reply; 14+ messages in thread
From: Daniel Hackney @ 2010-03-15 19:04 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> wrote:
> I have applied your patch thanks.

I'm glad that you found it useful!

> This is a the limit of what I can take without you signing the FSF
> papers. Would you consider signing them?

Absolutely. I submitted an application about a week ago (for my work on
package.el), but haven't heard back yet. I am certainly willing to sign
over these patches, if that makes things more convenient.

I can let you know once my papers have gone through. I definitely intend
to keep contributing to org-mode!

--
Daniel M. Hackney

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-15 19:04     ` Daniel Hackney
@ 2010-03-15 19:16       ` Carsten Dominik
  0 siblings, 0 replies; 14+ messages in thread
From: Carsten Dominik @ 2010-03-15 19:16 UTC (permalink / raw)
  To: Daniel Hackney; +Cc: emacs-orgmode


On Mar 15, 2010, at 8:04 PM, Daniel Hackney wrote:

> Carsten Dominik <carsten.dominik@gmail.com> wrote:
>> I have applied your patch thanks.
>
> I'm glad that you found it useful!
>
>> This is a the limit of what I can take without you signing the FSF
>> papers. Would you consider signing them?
>
> Absolutely. I submitted an application about a week ago (for my work  
> on
> package.el), but haven't heard back yet.

If you have other things besides org-mode, you mind want to get a  
"past and future changes to Emacs", which will cover anything you  
contribute to Emacs.


> I am certainly willing to sign
> over these patches, if that makes things more convenient.
>
> I can let you know once my papers have gone through.

Please do hat indeed, thanks.

- Carsten

> I definitely intend
> to keep contributing to org-mode!
>
> --
> Daniel M. Hackney

- Carsten

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

* Re: [PATCH 2/2] Fix adaptive filling.
  2010-03-15 15:48   ` Carsten Dominik
  2010-03-15 19:04     ` Daniel Hackney
@ 2010-06-03 15:11     ` Daniel Hackney
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel Hackney @ 2010-06-03 15:11 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> wrote:
> I have applied your patch thanks.
>
> This is a the limit of what I can take without you signing the FSF
>  papers. Would you consider signing them?

Just to let you know that I signed the FSF papers and it all went
through, so I am clear for code assignment stuff. Yeah, I know it's been
a little while since my patch ;)

--
Daniel M. Hackney

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

end of thread, other threads:[~2010-06-03 15:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-01 13:49 [PATCH 1/2] org-babel-oz: Fix line-endings Dan Hackney
2010-03-01 13:49 ` [PATCH 2/2] Fix adaptive filling Dan Hackney
2010-03-03 12:48   ` Carsten Dominik
2010-03-03 20:06     ` Austin Frank
2010-03-04  1:17   ` Samuel Wales
2010-03-04  1:25     ` Daniel Hackney
2010-03-11 17:13   ` Carsten Dominik
2010-03-12  2:55     ` Austin Frank
2010-03-12  4:57       ` Samuel Wales
2010-03-15 15:48   ` Carsten Dominik
2010-03-15 19:04     ` Daniel Hackney
2010-03-15 19:16       ` Carsten Dominik
2010-06-03 15:11     ` Daniel Hackney
2010-03-01 15:31 ` [PATCH 1/2] org-babel-oz: Fix line-endings Eric Schulte

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