浏览代码

Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode

Carsten Dominik 15 年之前
父节点
当前提交
a082001643
共有 5 个文件被更改,包括 69 次插入25 次删除
  1. 6 0
      contrib/babel/lisp/langs/org-babel-R.el
  2. 7 1
      contrib/babel/lisp/org-babel-tangle.el
  3. 20 14
      contrib/babel/lisp/org-babel.el
  4. 5 0
      lisp/ChangeLog
  5. 31 10
      lisp/org-timer.el

+ 6 - 0
contrib/babel/lisp/langs/org-babel-R.el

@@ -35,6 +35,12 @@
 
 
 (add-to-list 'org-babel-tangle-langs '("R" "R" "#!/usr/bin/env Rscript"))
 (add-to-list 'org-babel-tangle-langs '("R" "R" "#!/usr/bin/env Rscript"))
 
 
+(defconst org-babel-header-arg-names:R
+  '(width height bg units pointsize antialias quality compression
+	  res type family title fonts version paper encoding
+	  pagecentre colormodel useDingbats horizontal)
+  "R-specific header arguments.")
+
 (defun org-babel-expand-body:R (body params &optional processed-params)
 (defun org-babel-expand-body:R (body params &optional processed-params)
   (let* ((processed-params (or processed-params
   (let* ((processed-params (or processed-params
                                (org-babel-process-params params)))
                                (org-babel-process-params params)))

+ 7 - 1
contrib/babel/lisp/org-babel-tangle.el

@@ -40,6 +40,11 @@ to use when writing out the language to file, and an optional
 fourth element is a flag which when true indicates that the
 fourth element is a flag which when true indicates that the
 language does not support comments.")
 language does not support comments.")
 
 
+(defvar org-babel-tangle-w-comments nil
+  "Control the insertion of comments into tangled code.  Non-nil
+value will result in the insertion of comments for those
+languages with comment support.")
+
 (defun org-babel-load-file (file)
 (defun org-babel-load-file (file)
   "Load the contents of the Emacs Lisp source code blocks in the
   "Load the contents of the Emacs Lisp source code blocks in the
 org-mode formatted FILE.  This function will first export the
 org-mode formatted FILE.  This function will first export the
@@ -218,7 +223,8 @@ form
 
 
   (link source-name params body)"
   (link source-name params body)"
   (flet ((insert-comment (text)
   (flet ((insert-comment (text)
-                         (when commentable
+                         (when (and commentable
+				    org-babel-tangle-w-comments)
                            (insert "\n")
                            (insert "\n")
                            (comment-region (point) (progn (insert text) (point)))
                            (comment-region (point) (progn (insert text) (point)))
                            (end-of-line nil)
                            (end-of-line nil)

+ 20 - 14
contrib/babel/lisp/org-babel.el

@@ -571,21 +571,27 @@ with C-c C-c."
          (goto-char (match-end 0))))
          (goto-char (match-end 0))))
      (unless visited-p (kill-buffer (file-name-nondirectory ,file)))))
      (unless visited-p (kill-buffer (file-name-nondirectory ,file)))))
 
 
-(defun org-babel-params-from-properties ()
+(defun org-babel-params-from-properties (&optional lang)
   "Return an association list of any source block params which
   "Return an association list of any source block params which
 may be specified in the properties of the current outline entry."
 may be specified in the properties of the current outline entry."
   (save-match-data
   (save-match-data
-    (delq nil
-          (mapcar
-           (lambda (header-arg)
-             (let ((val (or (condition-case nil
-                                (org-entry-get (point) header-arg t)
-                              (error nil))
-                            (cdr (assoc header-arg org-file-properties)))))
-               (when val
-                 ;; (message "prop %s=%s" header-arg val) ;; debugging
-                 (cons (intern (concat ":" header-arg)) val))))
-           (mapcar 'symbol-name org-babel-header-arg-names)))))
+    (let (val sym)
+      (delq nil
+	    (mapcar
+	     (lambda (header-arg)
+	       (and (setq val
+			  (or (condition-case nil
+				  (org-entry-get (point) header-arg t)
+				(error nil))
+			      (cdr (assoc header-arg org-file-properties))))
+		    (cons (intern (concat ":" header-arg)) val)))
+	     (mapcar
+	      'symbol-name
+	      (append
+	       org-babel-header-arg-names
+	       (progn
+		 (setq sym (intern (concat "org-babel-header-arg-names:" lang)))
+		 (and (boundp sym) (eval sym))))))))))
 
 
 (defun org-babel-parse-src-block-match ()
 (defun org-babel-parse-src-block-match ()
   (let* ((lang (org-babel-clean-text-properties (match-string 1)))
   (let* ((lang (org-babel-clean-text-properties (match-string 1)))
@@ -603,7 +609,7 @@ may be specified in the properties of the current outline entry."
               (buffer-string)))
               (buffer-string)))
 	  (org-babel-merge-params
 	  (org-babel-merge-params
 	   org-babel-default-header-args
 	   org-babel-default-header-args
-           (org-babel-params-from-properties)
+           (org-babel-params-from-properties lang)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (org-babel-parse-header-arguments
 	   (org-babel-parse-header-arguments
             (org-babel-clean-text-properties (or (match-string 3) ""))))
             (org-babel-clean-text-properties (or (match-string 3) ""))))
@@ -617,7 +623,7 @@ may be specified in the properties of the current outline entry."
            (org-babel-clean-text-properties (match-string 5)))
            (org-babel-clean-text-properties (match-string 5)))
           (org-babel-merge-params
           (org-babel-merge-params
            org-babel-default-inline-header-args
            org-babel-default-inline-header-args
-           (org-babel-params-from-properties)
+           (org-babel-params-from-properties lang)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (org-babel-parse-header-arguments
            (org-babel-parse-header-arguments
             (org-babel-clean-text-properties (or (match-string 4) "")))))))
             (org-babel-clean-text-properties (or (match-string 4) "")))))))

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2010-05-28  Bastien Guerry  <bzg@altern.org>
+
+	* org-timer.el (org-timer-set-timer): Use a prefix argument.
+	See the docstring of the function.
+
 2010-05-24  Bastien Guerry  <bzg@altern.org>
 2010-05-24  Bastien Guerry  <bzg@altern.org>
 
 
 	* org-timer.el (org-timer-set-timer): Fix bug about cancelling
 	* org-timer.el (org-timer-set-timer): Fix bug about cancelling

+ 31 - 10
lisp/org-timer.el

@@ -305,15 +305,35 @@ VALUE can be `on', `off', or `pause'."
       (message "%d minute(s) %d seconds left before next time out"
       (message "%d minute(s) %d seconds left before next time out"
 	       rmins rsecs))))
 	       rmins rsecs))))
 
 
+(defun bzg-test (&optional test)
+  (interactive "P")
+  test)
+
 ;;;###autoload
 ;;;###autoload
-(defun org-timer-set-timer ()
-  "Set a timer."
-  (interactive)
-  (let ((minutes 
-	 (read-from-minibuffer 
-	  "How many minutes left? "
-	  (if (not (eq org-timer-default-timer 0))
-	      (number-to-string org-timer-default-timer)))))
+(defun org-timer-set-timer (&optional opt)
+  "Prompt for a duration and set a timer.
+
+If `org-timer-default-timer' is not zero, suggest this value as
+the default duration for the timer.  If a timer is already set,
+prompt the use if she wants to replace it.
+
+Called with a numeric prefix argument, use this numeric value as
+the duration of the timer.
+
+Called with a `C-u' prefix argument, use `org-timer-default-timer' 
+without prompting the user for a duration.
+
+With two `C-u' prefix argument, use `org-timer-default-timer'
+without prompting the user for a duration and automatically
+replace any running timer."
+  (interactive "P")
+  (let ((minutes (or (and (numberp opt) (number-to-string opt))
+		     (and (listp opt) (not (null opt))
+			  (number-to-string org-timer-default-timer))
+		     (read-from-minibuffer 
+		      "How many minutes left? "
+		      (if (not (eq org-timer-default-timer 0))
+			  (number-to-string org-timer-default-timer))))))
     (if (not (string-match "[0-9]+" minutes))
     (if (not (string-match "[0-9]+" minutes))
 	(org-timer-show-remaining-time)
 	(org-timer-show-remaining-time)
     (let* ((mins (string-to-number (match-string 0 minutes)))
     (let* ((mins (string-to-number (match-string 0 minutes)))
@@ -335,8 +355,9 @@ VALUE can be `on', `off', or `pause'."
 		(t (error "Not in an Org buffer"))))
 		(t (error "Not in an Org buffer"))))
 	   timer-set)
 	   timer-set)
       (if (or (and org-timer-current-timer
       (if (or (and org-timer-current-timer
-		     (y-or-n-p "Replace current timer? "))
-		(not org-timer-current-timer))
+		   (or (equal opt '(16))
+		       (y-or-n-p "Replace current timer? ")))
+	      (not org-timer-current-timer))
 	  (progn
 	  (progn
 	    (when org-timer-current-timer
 	    (when org-timer-current-timer
 	      (cancel-timer org-timer-current-timer))
 	      (cancel-timer org-timer-current-timer))