emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vladimir Lomov <lomov.vl@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2
Date: Fri, 20 Jul 2012 10:19:45 +0900	[thread overview]
Message-ID: <20120720011945.GD890@smoon> (raw)
In-Reply-To: <20120719123357.GC890@smoon>

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

** Vladimir Lomov [2012-07-19 21:33:57 +0900]:

> Hello,
> ** Eric Schulte [2012-07-18 22:13:45 -0600]:

>> Achim Gratz <Stromeko@nexgo.de> writes:

>>> Eric Schulte writes:
>>>> This attached alternate patch introduces two new compatibility macros
>>>> named `org-flet' and `org-labels' in org-macs.el.  These macros are
>>>> aliased to the appropriate cl macro depending on the version of Emacs in
>>>> use.

>>> Wouldn't you want to use defmacro instead of defalias?

>> Why?  Using `defalias' seems simpler because with `defmacro' I would
>> have to copy the macro arguments and stub out a trivial macro body.
>> Also, this way the version check only happens once (at load time),
>> rather than every time the macro is called.

>>> Also, I'd think that these two macros should go into org-compat.el
>>> instead of org-macs.el.

>> Agreed, I forgot about org-compat.  The alternate patch below moves
>> these definitions from org-macs.el to org-compat.el.

>> Thanks,

> [...]

> This is interesting, but seems not fully functional. After applying
> patch I tried export to html but got

> Symbol's function definition is void: matches

> I'll compare your and mine patches later.

I found the source of that message, in my patch I use `cl-flet*' for
`ob.el' (around lines 1264). I don't remember exactly why star version
is needed but it works.

I changed a bit Eric's patch with recent changes from Jambunathan and
checked it with simple "Export to HTML" on my real Org document, it
works.

I attached modified patch.

P.S. Seems I remember why I was confused: the `flet' function has to be
changed in one places to `cl-flet' but in others to `cl-flet*'.

---
WBR, Vladimir Lomov

-- 
Do YOU have redeeming social value?

[-- Attachment #2: 0001-replace-flet-labels-with-org-flet-org-labels.patch --]
[-- Type: text/plain, Size: 25563 bytes --]

From bdc1181b1860cf423f58fde19a9bf831c0f8dd9f Mon Sep 17 00:00:00 2001
From: Eric Schulte <eric.schulte@gmx.com>
Date: Wed, 18 Jul 2012 22:11:36 -0600
Subject: [PATCH] replace flet/labels with org-flet/org-labels

This patch ensure Org-mode will build on all supported versions of
Emacs, after the renaming of the cl macros behind the cl- prefix in the
recent Emacs trunk.

* lisp/org-compat.el (org-emacs-full-version): For checking versions
  smaller than the minor version.
  (org-flet): Compatibility function now that flet has been removed from
  cl-macs.
  (org-labels): Compatibility function now that labels has been removed
  from cl-macs.
* lisp/ob-R.el (org-compat): Require org-compat.
* lisp/ob-comint.el: Require org-compat.
* lisp/ob-exp.el (org-babel-exp-do-export): Switch to compatibility
  function.
* lisp/ob-gnuplot.el (org-babel-expand-body:gnuplot): Switch to
  compatibility function.
* lisp/ob-lob.el (org-babel-lob-get-info): Switch to compatibility
  function.
  (org-babel-lob-execute): Switch to compatibility function.
* lisp/ob-python.el (org-babel-python-evaluate-session): Switch to
  compatibility function.
* lisp/ob-ref.el (org-babel-ref-index-list): Switch to compatibility
  function.
* lisp/ob-sh.el (org-babel-sh-var-to-string): Switch to compatibility
  function.
* lisp/ob-tangle.el (org-babel-load-file): Switch to compatibility
  function.
  (org-babel-tangle): Switch to compatibility function.
  (org-babel-spec-to-string): Switch to compatibility function.
* lisp/ob.el (org-babel-view-src-block-info): Switch to compatibility
  function.
  (org-babel-execute-src-block): Switch to compatibility function.
  (org-babel-edit-distance): Switch to compatibility function.
  (org-babel-switch-to-session-with-code): Switch to compatibility
  function.
  (org-babel-sha1-hash): Switch to compatibility function.
  (org-babel-balanced-split): Switch to compatibility function.
  (org-babel-join-splits-near-ch): Switch to compatibility function.
  (org-babel-get-rownames): Switch to compatibility function.
  (org-babel-format-result): Switch to compatibility function.
  (org-babel-insert-result): Switch to compatibility function.
  (org-babel-examplize-region): Switch to compatibility function.
  (org-babel-merge-params): Switch to compatibility function.
  (org-babel-noweb-p): Switch to compatibility function.
  (org-babel-expand-noweb-references): Switch to compatibility function.
* lisp/org-bibtex.el (org-bibtex-headline): Switch to compatibility
  function.
  (org-bibtex-fleshout): Switch to compatibility function.
  (org-bibtex-read): Switch to compatibility function.
  (org-bibtex-write): Switch to compatibility function.
* lisp/org-exp-blocks.el (org-export-blocks-preprocess): Switch to
  compatibility function.
* lisp/org-exp.el (org-export-format-source-code-or-example): Switch to
  compatibility function.
* lisp/org-macs.el (org-called-interactively-p): Indentation fix.
* lisp/org-mouse.el (org-mouse-timestamp-today): Switch to compatibility
  function.
  (org-mouse-set-priority): Switch to compatibility function.
  (org-mouse-popup-global-menu): Switch to compatibility function.
  (org-mouse-context-menu): Switch to compatibility function.
* lisp/org-plot.el (org-plot/gnuplot-to-grid-data): Switch to
  compatibility function.
  (org-plot/gnuplot-script): Switch to compatibility function.
* lisp/org.el (org-entry-get): Switch to compatibility function.
  (org-fill-paragraph): Switch to compatibility function.
  (org-auto-fill-function): Switch to compatibility function.
---
 lisp/ob-awk.el         |  3 ++-
 lisp/ob-comint.el      |  3 ++-
 lisp/ob-exp.el         |  2 +-
 lisp/ob-gnuplot.el     |  2 +-
 lisp/ob-lob.el         |  4 ++--
 lisp/ob-python.el      |  2 +-
 lisp/ob-ref.el         |  2 +-
 lisp/ob-sh.el          |  2 +-
 lisp/ob-tangle.el      |  6 +++---
 lisp/ob.el             | 30 +++++++++++++++---------------
 lisp/org-bibtex.el     |  8 ++++----
 lisp/org-compat.el     | 21 +++++++++++++++++++++
 lisp/org-exp-blocks.el |  2 +-
 lisp/org-exp.el        |  2 +-
 lisp/org-macs.el       |  3 ++-
 lisp/org-mouse.el      |  8 ++++----
 lisp/org-plot.el       |  4 ++--
 lisp/org.el            |  6 +++---
 19 files changed, 69 insertions(+), 45 deletions(-)

diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el
index 682d802..de94a56 100644
--- a/lisp/ob-awk.el
+++ b/lisp/ob-awk.el
@@ -33,6 +33,7 @@
 ;;; Code:
 (require 'ob)
 (require 'ob-eval)
+(require 'org-compat)
 (eval-when-compile (require 'cl))
 
 (declare-function org-babel-ref-resolve "ob-ref" (ref))
@@ -96,7 +97,7 @@ called by `org-babel-execute-src-block'"
 
 (defun org-babel-awk-var-to-awk (var &optional sep)
   "Return a printed value of VAR suitable for parsing with awk."
-  (flet ((echo-var (v) (if (stringp v) v (format "%S" v))))
+  (org-flet ((echo-var (v) (if (stringp v) v (format "%S" v))))
     (cond
      ((and (listp var) (listp (car var)))
       (orgtbl-to-generic var  (list :sep (or sep "\t") :fmt #'echo-var)))
diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index a0712b9..f7403dc 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -31,6 +31,7 @@
 
 ;;; Code:
 (require 'ob)
+(require 'org-compat)
 (require 'comint)
 (eval-when-compile (require 'cl))
 (declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
@@ -74,7 +75,7 @@ or user `keyboard-quit' during execution of body."
 	(full-body (cadr (cdr (cdr meta)))))
     `(org-babel-comint-in-buffer ,buffer
        (let ((string-buffer "") dangling-text raw)
-	 (flet ((my-filt (text)
+	 (org-flet ((my-filt (text)
 			 (setq string-buffer (concat string-buffer text))))
 	   ;; setup filter
 	   (add-hook 'comint-output-filter-functions 'my-filt)
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 561d5f3..5c52ee2 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -219,7 +219,7 @@ org-mode text."
 (defun org-babel-exp-do-export (info type &optional hash)
   "Return a string with the exported content of a code block.
 The function respects the value of the :exports header argument."
-  (flet ((silently () (let ((session (cdr (assoc :session (nth 2 info)))))
+  (org-flet ((silently () (let ((session (cdr (assoc :session (nth 2 info)))))
 			(when (not (and session (equal "none" session)))
 			  (org-babel-exp-results info type 'silent))))
 	 (clean () (unless (eq type 'inline) (org-babel-remove-result info))))
diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el
index 5d07366..0f84643 100644
--- a/lisp/ob-gnuplot.el
+++ b/lisp/ob-gnuplot.el
@@ -88,7 +88,7 @@ code."
            (time-ind (or (plist-get params :timeind)
                          (when timefmt 1)))
            output)
-      (flet ((add-to-body (text)
+      (org-flet ((add-to-body (text)
                           (setq body (concat text "\n" body))))
         ;; append header argument settings to body
         (when title (add-to-body (format "set title '%s'" title))) ;; title
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index 1c0cf04..ab56d9e 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -97,7 +97,7 @@ if so then run the appropriate source block from the Library."
 ;;;###autoload
 (defun org-babel-lob-get-info ()
   "Return a Library of Babel function call as a string."
-  (flet ((nonempty (a b)
+  (org-flet ((nonempty (a b)
 		   (let ((it (match-string a)))
 		     (if (= (length it) 0) (match-string b) it))))
     (let ((case-fold-search t))
@@ -119,7 +119,7 @@ if so then run the appropriate source block from the Library."
 
 (defun org-babel-lob-execute (info)
   "Execute the lob call specified by INFO."
-  (flet ((mkinfo (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
+  (org-flet ((mkinfo (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
     (let* ((pre-params (org-babel-merge-params
 			org-babel-default-header-args
 			(org-babel-params-from-properties)
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 348248f..3f4273c 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -238,7 +238,7 @@ last statement in BODY, as elisp."
 If RESULT-TYPE equals 'output then return standard output as a
 string. If RESULT-TYPE equals 'value then return the value of the
 last statement in BODY, as elisp."
-  (flet ((send-wait () (comint-send-input nil t) (sleep-for 0 5))
+  (org-flet ((send-wait () (comint-send-input nil t) (sleep-for 0 5))
 	 (dump-last-value
 	  (tmp-file pp)
 	  (mapc
diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el
index 08cb4e3..6180e0b 100644
--- a/lisp/ob-ref.el
+++ b/lisp/ob-ref.el
@@ -222,7 +222,7 @@ to \"0:-1\"."
 	    (length (length lis))
             (portion (match-string 1 index))
             (remainder (substring index (match-end 0))))
-        (flet ((wrap (num) (if (< num 0) (+ length num) num))
+        (org-flet ((wrap (num) (if (< num 0) (+ length num) num))
                (open (ls) (if (and (listp ls) (= (length ls) 1)) (car ls) ls)))
           (open
            (mapcar
diff --git a/lisp/ob-sh.el b/lisp/ob-sh.el
index 1fbac1d..0d0c829 100644
--- a/lisp/ob-sh.el
+++ b/lisp/ob-sh.el
@@ -107,7 +107,7 @@ var of the same value."
 
 (defun org-babel-sh-var-to-string (var &optional sep)
   "Convert an elisp value to a string."
-  (flet ((echo-var (v) (if (stringp v) v (format "%S" v))))
+  (org-flet ((echo-var (v) (if (stringp v) v (format "%S" v))))
     (cond
      ((and (listp var) (listp (car var)))
       (orgtbl-to-generic var  (list :sep (or sep "\t") :fmt #'echo-var)))
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2af033c..74ebddf 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -142,7 +142,7 @@ This function exports the source code using
 `org-babel-tangle' and then loads the resulting file using
 `load-file'."
   (interactive "fFile to load: ")
-  (flet ((age (file)
+  (org-flet ((age (file)
               (float-time
                (time-subtract (current-time)
                               (nth 5 (or (file-attributes (file-truename file))
@@ -221,7 +221,7 @@ exported source code blocks by language."
                 she-banged)
            (mapc
             (lambda (spec)
-              (flet ((get-spec (name)
+              (org-flet ((get-spec (name)
                                (cdr (assoc name (nth 4 spec)))))
                 (let* ((tangle (get-spec :tangle))
                        (she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb))
@@ -412,7 +412,7 @@ form
 				       (if (stringp le) le (format "%S" le)))
 				     (eval el))))
 			    '(start-line file link source-name))))
-    (flet ((insert-comment (text)
+    (org-flet ((insert-comment (text)
             (when (and comments (not (string= comments "no"))
 		       (> (length text) 0))
 	      (when padline (insert "\n"))
diff --git a/lisp/ob.el b/lisp/ob.el
index 98ad40f..5c44835 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -340,7 +340,7 @@ This includes header arguments, language and name, and is largely
 a window into the `org-babel-get-src-block-info' function."
   (interactive)
   (let ((info (org-babel-get-src-block-info 'light)))
-    (flet ((full (it) (> (length it) 0))
+    (org-flet ((full (it) (> (length it) 0))
 	   (printf (fmt &rest args) (princ (apply #'format fmt args))))
       (when info
 	(with-help-window (help-buffer)
@@ -536,9 +536,9 @@ block."
 	     (indent (car (last info)))
 	     result cmd)
 	(unwind-protect
-	    (flet ((call-process-region (&rest args)
+	    (org-flet ((call-process-region (&rest args)
 		    (apply 'org-babel-tramp-handle-call-process-region args)))
-	      (flet ((lang-check (f)
+	      (org-flet ((lang-check (f)
 		       (let ((f (intern (concat "org-babel-execute:" f))))
 			 (when (fboundp f) f))))
 		(setq cmd
@@ -618,7 +618,7 @@ arguments and pop open the results in a preview buffer."
 	 (l2 (length s2))
 	 (dist (map 'vector (lambda (_) (make-vector (1+ l2) nil))
 		    (number-sequence 1 (1+ l1)))))
-    (flet ((in (i j) (aref (aref dist i) j))
+    (org-flet ((in (i j) (aref (aref dist i) j))
 	   (mmin (&rest lst) (apply #'min (remove nil lst))))
       (setf (aref (aref dist 0) 0) 0)
       (dolist (i (number-sequence 1 l1))
@@ -789,7 +789,7 @@ with a prefix argument then this is passed on to
 (defun org-babel-switch-to-session-with-code (&optional arg info)
   "Switch to code buffer and display session."
   (interactive "P")
-  (flet ((swap-windows
+  (org-flet ((swap-windows
 	  ()
 	  (let ((other-window-buffer (window-buffer (next-window))))
 	    (set-window-buffer (next-window) (current-buffer))
@@ -1017,7 +1017,7 @@ the current subtree."
     (setf (nth 2 info)
 	  (sort (copy-sequence (nth 2 info))
 		(lambda (a b) (string< (car a) (car b)))))
-    (labels ((rm (lst)
+    (org-labels ((rm (lst)
 		 (dolist (p '("replace" "silent" "append" "prepend"))
 		   (setq lst (remove p lst)))
 		 lst)
@@ -1264,7 +1264,7 @@ ALTS is a cons of two character options where each option may be
 either the numeric code of a single character or a list of
 character alternatives.  For example to split on balanced
 instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
-  (flet ((matches (ch spec) (if (listp spec) (member ch spec) (equal spec ch)))
+  (org-flet* ((matches (ch spec) (if (listp spec) (member ch spec) (equal spec ch)))
 	 (matched (ch last)
 		  (if (consp alts)
 		      (and (matches ch (cdr alts))
@@ -1292,7 +1292,7 @@ instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
 
 (defun org-babel-join-splits-near-ch (ch list)
   "Join splits where \"=\" is on either end of the split."
-  (flet ((last= (str) (= ch (aref str (1- (length str)))))
+  (org-flet ((last= (str) (= ch (aref str (1- (length str)))))
          (first= (str) (= ch (aref str 0))))
     (reverse
      (org-reduce (lambda (acc el)
@@ -1389,7 +1389,7 @@ names."
 Return a cons cell, the `car' of which contains the TABLE less
 colnames, and the `cdr' of which contains a list of the column
 names.  Note: this function removes any hlines in TABLE."
-  (flet ((trans (table) (apply #'mapcar* #'list table)))
+  (org-flet ((trans (table) (apply #'mapcar* #'list table)))
     (let* ((width (apply 'max
 			 (mapcar (lambda (el) (if (listp el) (length el) 0)) table)))
            (table (trans (mapcar (lambda (row)
@@ -1826,7 +1826,7 @@ If the path of the link is a file path it is expanded using
 
 (defun org-babel-format-result (result &optional sep)
   "Format RESULT for writing to file."
-  (flet ((echo-res (result)
+  (org-flet ((echo-res (result)
 		   (if (stringp result) result (format "%S" result))))
     (if (listp result)
 	;; table result
@@ -1933,7 +1933,7 @@ code ---- the results are extracted in the syntax of the source
 	   ((member "prepend" result-params)))) ; already there
 	(setq results-switches
 	      (if results-switches (concat " " results-switches) ""))
-	(flet ((wrap (start finish)
+	(org-flet ((wrap (start finish)
 		     (goto-char end) (insert (concat finish "\n"))
 		     (goto-char beg) (insert (concat start "\n"))
 		     (goto-char end) (goto-char (point-at-eol))
@@ -2058,7 +2058,7 @@ file's directory then expand relative links."
 (defun org-babel-examplize-region (beg end &optional results-switches)
   "Comment out region using the inline '==' or ': ' org example quote."
   (interactive "*r")
-  (flet ((chars-between (b e)
+  (org-flet ((chars-between (b e)
 			(not (string-match "^[\\s]*$" (buffer-substring b e))))
 	 (maybe-cap (str) (if org-babel-capitalize-examplize-region-markers
 			      (upcase str) str)))
@@ -2106,7 +2106,7 @@ parameters when merging lists."
 		 (cdr (assoc 'exports org-babel-common-header-args-w-values))))
 	(variable-index 0)
 	params results exports tangle noweb cache vars shebang comments padline)
-    (flet ((e-merge (exclusive-groups &rest result-params)
+    (org-flet ((e-merge (exclusive-groups &rest result-params)
              ;; maintain exclusivity of mutually exclusive parameters
              (let (output)
                (mapc (lambda (new-params)
@@ -2218,7 +2218,7 @@ header argument from buffer or subtree wide properties.")
 (defun org-babel-noweb-p (params context)
   "Check if PARAMS require expansion in CONTEXT.
 CONTEXT may be one of :tangle, :export or :eval."
-  (flet ((intersect (as bs)
+  (org-flet ((intersect (as bs)
 		       (when as
 			 (if (member (car as) bs)
 			     (car as)
@@ -2267,7 +2267,7 @@ block but are passed literally to the \"example-block\"."
 	 (rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|"
 			    ":noweb-ref[ \t]+" "\\)"))
          (new-body "") index source-name evaluate prefix blocks-in-buffer)
-    (flet ((nb-add (text) (setq new-body (concat new-body text)))
+    (org-flet ((nb-add (text) (setq new-body (concat new-body text)))
 	   (c-wrap (text)
 		   (with-temp-buffer
 		     (funcall (intern (concat lang "-mode")))
diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index dfc1afe..b6f7d7e 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -309,7 +309,7 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
 
 (defun org-bibtex-headline ()
   "Return a bibtex entry of the given headline as a string."
-  (flet ((val (key lst) (cdr (assoc key lst)))
+  (org-flet ((val (key lst) (cdr (assoc key lst)))
          (to (string) (intern (concat ":" string)))
          (from (key) (substring (symbol-name key) 1))
          (flatten (&rest lsts)
@@ -406,7 +406,7 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
 (defun org-bibtex-fleshout (type &optional optional)
   "Fleshout the current heading, ensuring that all required fields are present.
 With optional argument OPTIONAL, also prompt for optional fields."
-  (flet ((val (key lst) (cdr (assoc key lst)))
+  (org-flet ((val (key lst) (cdr (assoc key lst)))
 	 (keyword (name) (intern (concat ":" (downcase name))))
          (name (keyword) (substring (symbol-name keyword) 1)))
     (dolist (field (append
@@ -600,7 +600,7 @@ With a prefix arg, query for optional fields."
   "Read a bibtex entry and save to `org-bibtex-entries'.
 This uses `bibtex-parse-entry'."
   (interactive)
-  (flet ((keyword (str) (intern (concat ":" (downcase str))))
+  (org-flet ((keyword (str) (intern (concat ":" (downcase str))))
          (clean-space (str) (replace-regexp-in-string
                              "[[:space:]\n\r]+" " " str))
          (strip-delim (str)	     ; strip enclosing "..." and {...}
@@ -626,7 +626,7 @@ This uses `bibtex-parse-entry'."
     (error "No entries in `org-bibtex-entries'."))
   (let ((entry (pop org-bibtex-entries))
 	(org-special-properties nil)) ; avoids errors with `org-entry-put'
-    (flet ((val (field) (cdr (assoc field entry)))
+    (org-flet ((val (field) (cdr (assoc field entry)))
 	   (togtag (tag) (org-toggle-tag tag 'on)))
       (org-insert-heading)
       (insert (val :title))
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 51461e8..3817f68 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -110,6 +110,35 @@ any other entries, and any resulting duplicates will be removed entirely."
 	    t))
       t)))
 
+(defun org-emacs-full-version ()
+  (mapcar #'string-to-number (split-string emacs-version "\\.")))
+
+\f
+;;; cl macros no longer available in the trunk
+(defalias 'org-flet (if (or (> emacs-major-version 24)
+			    (and (= emacs-major-version 24)
+				 (let ((full (org-emacs-full-version)))
+				   (and (third full)
+					(> (third full) 1)))))
+			'cl-flet
+		      'flet))
+
+(defalias 'org-flet* (if (or (> emacs-major-version 24)
+			    (and (= emacs-major-version 24)
+				 (let ((full (org-emacs-full-version)))
+				   (and (third full)
+					(> (third full) 1)))))
+			'cl-flet*
+		      'flet))
+
+(defalias 'org-labels (if (or (> emacs-major-version 24)
+			      (and (= emacs-major-version 24)
+				   (let ((full (org-emacs-full-version)))
+				     (and (third full)
+					  (> (third full) 1)))))
+			  'cl-labels
+			'labels))
+
 ;;;; Emacs/XEmacs compatibility
 
 ;; Keys
diff --git a/lisp/org-exp-blocks.el b/lisp/org-exp-blocks.el
index 3861bc3..fba7e03 100644
--- a/lisp/org-exp-blocks.el
+++ b/lisp/org-exp-blocks.el
@@ -170,7 +170,7 @@ which defaults to the value of `org-export-blocks-witheld'."
 	  (types '())
 	  matched indentation type func
 	  start end body headers preserve-indent progress-marker)
-      (flet ((interblock (start end)
+      (org-flet ((interblock (start end)
 			 (mapcar (lambda (pair) (funcall (second pair) start end))
 				 org-export-interblocks)))
 	(goto-char (point-min))
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index d1084d7..8d4ed4d 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2734,7 +2734,7 @@ INDENT was the original indentation of the block."
 	      (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
 	      (cond
 	       ((and lang org-export-latex-listings)
-		(flet ((make-option-string
+		(org-flet ((make-option-string
 			(pair)
 			(concat (first pair)
 				(if (> (length (second pair)) 0)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 1c25249..5e74f25 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -58,7 +58,8 @@
      (if (or (> emacs-major-version 23)
 	     (and (>= emacs-major-version 23)
 		  (>= emacs-minor-version 2)))
-	 `(with-no-warnings (called-interactively-p ,kind)) ;; defined with no argument in <=23.1
+	 ;; defined with no argument in <=23.1
+	 `(with-no-warnings (called-interactively-p ,kind))
        `(interactive-p))))
 (def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp)))
 
diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index 57e9575..81e4724 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -269,7 +269,7 @@ after the current heading."
 
 For the acceptable UNITS, see `org-timestamp-change'."
   (interactive)
-  (flet ((org-read-date (&rest rest) (current-time)))
+  (org-flet ((org-read-date (&rest rest) (current-time)))
      (org-time-stamp nil))
   (when shift
     (org-timestamp-change shift units)))
@@ -375,7 +375,7 @@ nor a function, elements of KEYWORDS are used directly."
 
 (defun org-mouse-set-priority (priority)
   "Set the priority of the current headline to PRIORITY."
-  (flet ((read-char-exclusive () priority))
+  (org-flet ((read-char-exclusive () priority))
     (org-priority)))
 
 (defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]"
@@ -532,7 +532,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
      ,@(org-mouse-keyword-menu
 	(mapcar 'car org-agenda-custom-commands)
 	#'(lambda (key)
-	   (eval `(flet ((read-char-exclusive () (string-to-char ,key)))
+	   (eval `(org-flet ((read-char-exclusive () (string-to-char ,key)))
 		      (org-agenda nil))))
 	nil
 	#'(lambda (key)
@@ -625,7 +625,7 @@ This means, between the beginning of line and the point."
 (defun org-mouse-context-menu (&optional event)
   (let ((stamp-prefixes (list org-deadline-string org-scheduled-string))
 	(contextlist (org-context)))
-    (flet ((get-context (context) (org-mouse-get-context contextlist context)))
+    (org-flet ((get-context (context) (org-mouse-get-context contextlist context)))
   (cond
    ((org-mouse-mark-active)
     (let ((region-string (buffer-substring (region-beginning) (region-end))))
diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index f44694f..0f3e18b 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -160,7 +160,7 @@ and dependant variables."
     (with-temp-file data-file
       (let ((num-rows (length table)) (num-cols (length (first table)))
 	    front-edge back-edge)
-	(flet ((gnuplot-row (col row value)
+	(org-flet ((gnuplot-row (col row value)
 			    (setf col (+ 1 col)) (setf row (+ 1 row))
 			    (format "%f  %f  %f\n%f  %f  %f\n"
 				    col (- row 0.5) value ;; lower edge
@@ -209,7 +209,7 @@ manner suitable for prepending to a user-specified script."
 		     ('3d "splot")
 		     ('grid "splot")))
 	 (script "reset") plot-lines)
-    (flet ((add-to-script (line) (setf script (format "%s\n%s" script line))))
+    (org-flet ((add-to-script (line) (setf script (format "%s\n%s" script line))))
       (when file ;; output file
 	(add-to-script (format "set term %s" (file-name-extension file)))
 	(add-to-script (format "set output '%s'" file)))
diff --git a/lisp/org.el b/lisp/org.el
index 4241168..575fb7c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14342,7 +14342,7 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
 			       (assoc property org-global-properties)
 			       (assoc property org-global-properties-fixed))))
 	      val)
-	  (flet ((ap (key)
+	  (org-flet ((ap (key)
 		     (when (re-search-forward
 			    (org-re-property key) (cdr range) t)
 		       (setq props
@@ -20787,7 +20787,7 @@ the functionality can be provided as a fall-back.")
 		       (throw 'exit nil))))))
 	     ;; Use `fill-paragraph' with buffer narrowed to item
 	     ;; without any child, and with our computed PREFIX.
-	     (flet ((fill-context-prefix (from to &optional flr) prefix))
+	     (org-flet ((fill-context-prefix (from to &optional flr) prefix))
 	       (save-restriction
 		 (narrow-to-region beg end)
 		 (save-excursion (fill-paragraph justify)))) t))
@@ -20858,7 +20858,7 @@ the functionality can be provided as a fall-back.")
       (cond ((setq itemp (org-in-item-p))
 	     (progn
 	       (setq prefix (make-string (org-list-item-body-column itemp) ?\ ))
-	       (flet ((fill-context-prefix (from to &optional flr) prefix))
+	       (org-flet ((fill-context-prefix (from to &optional flr) prefix))
 		 (do-auto-fill))))
 	    (orgstruct-is-++
 	     (org-let org-fb-vars
-- 
1.7.11.2


  reply	other threads:[~2012-07-20  1:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18  7:03 The "problem" with `flet' in Org-mode and (future) Emacs 24.2 Vladimir Lomov
2012-07-18 16:35 ` Eric Schulte
2012-07-18 18:33   ` Achim Gratz
2012-07-19  4:13     ` Eric Schulte
2012-07-19  6:27       ` Achim Gratz
2012-07-19 12:33       ` Vladimir Lomov
2012-07-20  1:19         ` Vladimir Lomov [this message]
2012-07-20  3:00           ` Vladimir Lomov
2012-07-20 17:43             ` Eric Schulte
2012-07-22  0:13               ` Vladimir Lomov
2012-07-22 19:30                 ` Achim Gratz
2012-07-25 15:26                   ` Eric Schulte
2012-07-25 16:45                     ` Achim Gratz
2012-07-25 16:54                       ` Eric Schulte
2012-07-26 12:28                     ` Bastien
2012-07-26 13:19                       ` Bastien
2012-07-26 14:36                         ` Bastien
2012-07-23 17:41               ` Achim Gratz
2012-07-19 14:12       ` Jambunathan K
2012-07-18 18:18 ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120720011945.GD890@smoon \
    --to=lomov.vl@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).