* The "problem" with `flet' in Org-mode and (future) Emacs 24.2 @ 2012-07-18 7:03 Vladimir Lomov 2012-07-18 16:35 ` Eric Schulte 2012-07-18 18:18 ` Achim Gratz 0 siblings, 2 replies; 20+ messages in thread From: Vladimir Lomov @ 2012-07-18 7:03 UTC (permalink / raw) To: Emacs Org Mode [-- Attachment #1: Type: text/plain, Size: 891 bytes --] Hello, I'm using Emacs compiled from BZR trunk and Org-mode compiled from GIT. Begining from some revision (I don't remember exact revno) function `flet' was declared obsolete so Org-mode compilation is accompanied with warnings about that. If just ignore them then I get malfunction Org-mode. I made patch to change all `flet's to appropriate functions and it works. The problem is that these functions are new too. As I see it, the patch will "break" compatability with current and older versions of Emacs. WDYT? P.S. As I remember there are at least two problems with Org-mode compiled _without_ patch: exporting to HTML and code tangling. -- Nouvelle cuisine, n.: French for "not enough food". Continental breakfast, n.: English for "not enough food". Tapas, n.: Spanish for "not enough food". Dim Sum, n.: Chinese for more food than you've ever seen in your entire life. [-- Attachment #2: flet2cl-flet.patch.bz2 --] [-- Type: application/x-bzip2, Size: 7916 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 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-18 18:18 ` Achim Gratz 1 sibling, 1 reply; 20+ messages in thread From: Eric Schulte @ 2012-07-18 16:35 UTC (permalink / raw) To: Vladimir Lomov; +Cc: Emacs Org Mode [-- Attachment #1: Type: text/plain, Size: 1073 bytes --] Vladimir Lomov <lomov.vl@gmail.com> writes: > Hello, > > I'm using Emacs compiled from BZR trunk and Org-mode compiled from GIT. > > Begining from some revision (I don't remember exact revno) function > `flet' was declared obsolete so Org-mode compilation is accompanied with > warnings about that. > > If just ignore them then I get malfunction Org-mode. I made patch to > change all `flet's to appropriate functions and it works. > > The problem is that these functions are new too. As I see it, the patch > will "break" compatability with current and older versions of Emacs. > > WDYT? > > P.S. As I remember there are at least two problems with Org-mode > compiled _without_ patch: exporting to HTML and code tangling. 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. With this patch I am able to successfully compile Org-mode on both trunk and Emacs 24 (I haven't tried on older versions). Best, [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-replace-flet-labels-with-org-flet-org-labels.patch --] [-- Type: text/x-patch, Size: 22453 bytes --] From 8687829d88513dd4af0eb254a0e0b0a28f4263d0 Mon Sep 17 00:00:00 2001 From: Eric Schulte <eric.schulte@gmx.com> Date: Wed, 18 Jul 2012 07:35:46 -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/ob-awk.el | 2 +- lisp/ob-comint.el | 2 +- 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-exp-blocks.el | 2 +- lisp/org-exp.el | 2 +- lisp/org-macs.el | 25 ++++++++++++++++++++++++- lisp/org-mouse.el | 8 ++++---- lisp/org-odt.el | 4 ++-- lisp/org-plot.el | 4 ++-- lisp/org.el | 6 +++--- 18 files changed, 68 insertions(+), 45 deletions(-) diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el index 682d802..f89f775 100644 --- a/lisp/ob-awk.el +++ b/lisp/ob-awk.el @@ -96,7 +96,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..a560401 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -74,7 +74,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-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..0c0efaf 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -45,6 +45,28 @@ (declare-function org-add-props "org-compat" (string plist &rest props)) (declare-function org-string-match-p "org-compat" (&rest args)) +;; emacs-version +;; 24 -> "24.1.1" +;; trunk -> "24.1.50.3" +(defun org-emacs-full-version () + (mapcar #'string-to-number (split-string emacs-version "\\."))) + +(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)) + (defmacro org-with-gensyms (symbols &rest body) `(let ,(mapcar (lambda (s) `(,s (make-symbol (concat "--" (symbol-name ',s))))) symbols) @@ -58,7 +80,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-odt.el b/lisp/org-odt.el index e24c8a5..2b52c87 100644 --- a/lisp/org-odt.el +++ b/lisp/org-odt.el @@ -2033,8 +2033,8 @@ ATTR is a string of other attributes of the a element." (defun org-odt-do-image-size (probe-method file &optional dpi anchor-type) (setq dpi (or dpi org-export-odt-pixels-per-inch)) (setq anchor-type (or anchor-type "paragraph")) - (flet ((size-in-cms (size-in-pixels) - (flet ((pixels-to-cms (pixels) + (org-flet ((size-in-cms (size-in-pixels) + (org-flet ((pixels-to-cms (pixels) (let* ((cms-per-inch 2.54) (inches (/ pixels dpi))) (* cms-per-inch inches)))) 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 [-- Attachment #3: Type: text/plain, Size: 46 bytes --] -- Eric Schulte http://cs.unm.edu/~eschulte ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-18 16:35 ` Eric Schulte @ 2012-07-18 18:33 ` Achim Gratz 2012-07-19 4:13 ` Eric Schulte 0 siblings, 1 reply; 20+ messages in thread From: Achim Gratz @ 2012-07-18 18:33 UTC (permalink / raw) To: emacs-orgmode 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? Also, I'd think that these two macros should go into org-compat.el instead of org-macs.el. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf rackAttack: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-18 18:33 ` Achim Gratz @ 2012-07-19 4:13 ` Eric Schulte 2012-07-19 6:27 ` Achim Gratz ` (2 more replies) 0 siblings, 3 replies; 20+ messages in thread From: Eric Schulte @ 2012-07-19 4:13 UTC (permalink / raw) To: Achim Gratz; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 834 bytes --] 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, [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-replace-flet-labels-with-org-flet-org-labels.patch --] [-- Type: text/x-patch, Size: 26104 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-odt.el (org-odt-do-image-size): 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-odt.el | 4 ++-- 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,27 @@ 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-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-odt.el b/lisp/org-odt.el index e24c8a5..2b52c87 100644 --- a/lisp/org-odt.el +++ b/lisp/org-odt.el @@ -2033,8 +2033,8 @@ ATTR is a string of other attributes of the a element." (defun org-odt-do-image-size (probe-method file &optional dpi anchor-type) (setq dpi (or dpi org-export-odt-pixels-per-inch)) (setq anchor-type (or anchor-type "paragraph")) - (flet ((size-in-cms (size-in-pixels) - (flet ((pixels-to-cms (pixels) + (org-flet ((size-in-cms (size-in-pixels) + (org-flet ((pixels-to-cms (pixels) (let* ((cms-per-inch 2.54) (inches (/ pixels dpi))) (* cms-per-inch inches)))) 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 [-- Attachment #3: Type: text/plain, Size: 46 bytes --] -- Eric Schulte http://cs.unm.edu/~eschulte ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-19 4:13 ` Eric Schulte @ 2012-07-19 6:27 ` Achim Gratz 2012-07-19 12:33 ` Vladimir Lomov 2012-07-19 14:12 ` Jambunathan K 2 siblings, 0 replies; 20+ messages in thread From: Achim Gratz @ 2012-07-19 6:27 UTC (permalink / raw) To: emacs-orgmode Eric Schulte writes: > 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. I confused defalias and defsubst, so please disregard the comment. I tested the new patch with Emacs 24.1 and Emacs 23.3 on Linux, so as far as the test coverage goes everything is fine. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Wavetables for the Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 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 2012-07-19 14:12 ` Jambunathan K 2 siblings, 1 reply; 20+ messages in thread From: Vladimir Lomov @ 2012-07-19 12:33 UTC (permalink / raw) To: emacs-orgmode 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. --- WBR, Vladimir Lomov -- Never underestimate the bandwidth of a station wagon full of tapes. -- Dr. Warren Jackson, Director, UTCS ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-19 12:33 ` Vladimir Lomov @ 2012-07-20 1:19 ` Vladimir Lomov 2012-07-20 3:00 ` Vladimir Lomov 0 siblings, 1 reply; 20+ messages in thread From: Vladimir Lomov @ 2012-07-20 1:19 UTC (permalink / raw) To: emacs-orgmode [-- 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 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-20 1:19 ` Vladimir Lomov @ 2012-07-20 3:00 ` Vladimir Lomov 2012-07-20 17:43 ` Eric Schulte 0 siblings, 1 reply; 20+ messages in thread From: Vladimir Lomov @ 2012-07-20 3:00 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1274 bytes --] Hello, ** Vladimir Lomov [2012-07-20 10:19:45 +0900]: > ** Vladimir Lomov [2012-07-19 21:33:57 +0900]: >> Hello, >>> ** Eric Schulte [2012-07-18 22:13:45 -0600]: >>> 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. [...] >> 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 was too rush, I compared again Eric's patch with mine and found two discrepancy (actually I faced with a problem checked all again). I hope this is final patch. --- WBR, Vladimir Lomov -- Q: How many Zen masters does it take to screw in a light bulb? A: None. The Universe spins the bulb, and the Zen master stays out of the way. [-- Attachment #2: 0001-replace-flet-labels-with-org-flet-org-labels.patch --] [-- Type: text/plain, Size: 25566 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-labels ((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 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-20 3:00 ` Vladimir Lomov @ 2012-07-20 17:43 ` Eric Schulte 2012-07-22 0:13 ` Vladimir Lomov 2012-07-23 17:41 ` Achim Gratz 0 siblings, 2 replies; 20+ messages in thread From: Eric Schulte @ 2012-07-20 17:43 UTC (permalink / raw) To: Vladimir Lomov; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 923 bytes --] >>>> 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. >>> 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. > Okay, I've noticed a number of these errors as well. It looks like the old version of flet allowed the definition of recursive functions, but the new cl-flet does not. Below find my previous patch which now uses cl-flet* instead of cl-flet in org-flet. This should be a universal fix. Best, [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-replace-flet-labels-with-org-flet-org-labels.patch --] [-- Type: text/x-patch, Size: 25333 bytes --] From 29dfbf1e3b6db2ca91198c176f8a9b085059a548 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 +++--- 18 files changed, 67 insertions(+), 43 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 b24cd90..41ae999 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -110,6 +110,27 @@ 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-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 [-- Attachment #3: Type: text/plain, Size: 46 bytes --] -- Eric Schulte http://cs.unm.edu/~eschulte ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-20 17:43 ` Eric Schulte @ 2012-07-22 0:13 ` Vladimir Lomov 2012-07-22 19:30 ` Achim Gratz 2012-07-23 17:41 ` Achim Gratz 1 sibling, 1 reply; 20+ messages in thread From: Vladimir Lomov @ 2012-07-22 0:13 UTC (permalink / raw) To: Eric Schulte; +Cc: Emacs Org mode Hello, ** Eric Schulte [2012-07-20 11:43:45 -0600]: [...] > Okay, I've noticed a number of these errors as well. It looks like the > old version of flet allowed the definition of recursive functions, but > the new cl-flet does not. > Below find my previous patch which now uses cl-flet* instead of cl-flet > in org-flet. This should be a universal fix. > Best, Thanks, would work fine with this small change: --- 0001-replace-flet-labels-with-org-flet-org-labels.patch.orig 2012-07-22 09:10:44.000000000 +0900 +++ 0001-replace-flet-labels-with-org-flet-org-labels.patch 2012-07-21 23:09:37.000000000 +0900 @@ -370,7 +370,7 @@ "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) ++ (org-labels ((intersect (as bs) (when as (if (member (car as) bs) (car as) --- WBR, Vladimir Lomov -- The core is not frozen, but slushy. -- Larry Wall in <199705101952.MAA00756@wall.org> ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-22 0:13 ` Vladimir Lomov @ 2012-07-22 19:30 ` Achim Gratz 2012-07-25 15:26 ` Eric Schulte 0 siblings, 1 reply; 20+ messages in thread From: Achim Gratz @ 2012-07-22 19:30 UTC (permalink / raw) To: emacs-orgmode Vladimir Lomov writes: > Thanks, would work fine with this small change: Thanks, but please do not patch a patch file... Eric, that leaves: In org-babel-edit-distance: ob.el:624:37:Warning: function `map' from cl package called at runtime which the byte-compiler did not pick up on before. If it can be replaced by a simple (vector (mapcar ...)) that would be preferrable I'd think. And these two in org-clock: In org-clock-special-range: org-clock.el:2029:83:Warning: function `concatenate' from cl package called at runtime In org-clocktable-shift: org-clock.el:2107:71:Warning: function `concatenate' from cl package called at runtime which look like a simple concat might work just as well. The tests are still pass with these changes, however I don't know if these functions are actually exercised. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2: http://Synth.Stromeko.net/Downloads.html#WaldorfSDada ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-22 19:30 ` Achim Gratz @ 2012-07-25 15:26 ` Eric Schulte 2012-07-25 16:45 ` Achim Gratz 2012-07-26 12:28 ` Bastien 0 siblings, 2 replies; 20+ messages in thread From: Eric Schulte @ 2012-07-25 15:26 UTC (permalink / raw) To: Achim Gratz; +Cc: emacs-orgmode I've just applied this patch including the input from both Achim and Vladimir (thanks). I also applied another patches fixing the other cl related build issues mentioned by Achim. The build now succeeds on the latest Emacs without generating any warnings and all tests pass (although it sounds like we could use more test coverage). Thanks, -- Eric Schulte http://cs.unm.edu/~eschulte ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 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 1 sibling, 1 reply; 20+ messages in thread From: Achim Gratz @ 2012-07-25 16:45 UTC (permalink / raw) To: emacs-orgmode Eric Schulte writes: > I also applied another patches fixing the other cl related build issues > mentioned by Achim. The build now succeeds on the latest Emacs without > generating any warnings and all tests pass (although it sounds like we > could use more test coverage). I don't think d7a8b6636a (replace cl concatenate with concat) is correct, (concat 'string ...) bombs even though it doesn't get triggered in the test suite (remove the 'string). Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Wavetables for the Terratec KOMPLEXER: http://Synth.Stromeko.net/Downloads.html#KomplexerWaves ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-25 16:45 ` Achim Gratz @ 2012-07-25 16:54 ` Eric Schulte 0 siblings, 0 replies; 20+ messages in thread From: Eric Schulte @ 2012-07-25 16:54 UTC (permalink / raw) To: Achim Gratz; +Cc: emacs-orgmode Achim Gratz <Stromeko@nexgo.de> writes: > Eric Schulte writes: >> I also applied another patches fixing the other cl related build issues >> mentioned by Achim. The build now succeeds on the latest Emacs without >> generating any warnings and all tests pass (although it sounds like we >> could use more test coverage). > > I don't think d7a8b6636a (replace cl concatenate with concat) is > correct, (concat 'string ...) bombs even though it doesn't get triggered > in the test suite (remove the 'string). > Oh! how careless of me, I've just pushed up a fix. Thanks for pointing this out. > > > Regards, > Achim. -- Eric Schulte http://cs.unm.edu/~eschulte ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-25 15:26 ` Eric Schulte 2012-07-25 16:45 ` Achim Gratz @ 2012-07-26 12:28 ` Bastien 2012-07-26 13:19 ` Bastien 1 sibling, 1 reply; 20+ messages in thread From: Bastien @ 2012-07-26 12:28 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode Hi Eric, Eric Schulte <eric.schulte@gmx.com> writes: > I've just applied this patch including the input from both Achim and > Vladimir (thanks). > > I also applied another patches fixing the other cl related build issues > mentioned by Achim. The build now succeeds on the latest Emacs without > generating any warnings and all tests pass (although it sounds like we > could use more test coverage). This commit http://orgmode.org/w/?p=org-mode.git;a=commit;h=63b5f8 breaks things for me. My Emacs version is 24.1.50.3 (built from trunk yesterday) and Org aliases org-flet to cl-flet* which doesn't exist here. Can you check and fix this? -- Bastien ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-26 12:28 ` Bastien @ 2012-07-26 13:19 ` Bastien 2012-07-26 14:36 ` Bastien 0 siblings, 1 reply; 20+ messages in thread From: Bastien @ 2012-07-26 13:19 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode Bastien <bzg@gnu.org> writes: > This commit > > http://orgmode.org/w/?p=org-mode.git;a=commit;h=63b5f8 > > breaks things for me. > > My Emacs version is 24.1.50.3 (built from trunk yesterday) and Org > aliases org-flet to cl-flet* which doesn't exist here. > > Can you check and fix this? Well, hold on, I'm recompiling Emacs, as my cl-macs.el seemed to date from way before two days ago. -- Bastien ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-26 13:19 ` Bastien @ 2012-07-26 14:36 ` Bastien 0 siblings, 0 replies; 20+ messages in thread From: Bastien @ 2012-07-26 14:36 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode Bastien <bzg@gnu.org> writes: > Well, hold on, I'm recompiling Emacs, as my cl-macs.el seemed to > date from way before two days ago. With a fresh Emacs things are fine. Sorry for the noise. -- Bastien ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-20 17:43 ` Eric Schulte 2012-07-22 0:13 ` Vladimir Lomov @ 2012-07-23 17:41 ` Achim Gratz 1 sibling, 0 replies; 20+ messages in thread From: Achim Gratz @ 2012-07-23 17:41 UTC (permalink / raw) To: emacs-orgmode Eric Schulte writes: > Okay, I've noticed a number of these errors as well. It looks like the > old version of flet allowed the definition of recursive functions, but > the new cl-flet does not. The defalias checks for the wrong Emacs version. I've just built another Emacs24 which got version 24.1.2, of which the "2" really is the build number; this should fix it (trunk starts from 24.1.50.1): diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 41ae999..ad04ccd 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -115,19 +115,11 @@ (defun org-emacs-full-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))))) +(defalias 'org-flet (if (org-version-check "24.1.50" "cl" :predicate) '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))))) +(defalias 'org-labels (if (org-version-check "24.1.50" "cl" :predicate) 'cl-labels 'labels)) Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf Q+, Q and microQ: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 2012-07-19 4:13 ` Eric Schulte 2012-07-19 6:27 ` Achim Gratz 2012-07-19 12:33 ` Vladimir Lomov @ 2012-07-19 14:12 ` Jambunathan K 2 siblings, 0 replies; 20+ messages in thread From: Jambunathan K @ 2012-07-19 14:12 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode Thanks. I have taken care for org-odt.el. Any `flet's in org-e-odt.el will also be removed in the next commit. -- ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: The "problem" with `flet' in Org-mode and (future) Emacs 24.2 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:18 ` Achim Gratz 1 sibling, 0 replies; 20+ messages in thread From: Achim Gratz @ 2012-07-18 18:18 UTC (permalink / raw) To: emacs-orgmode Vladimir Lomov writes: > Begining from some revision (I don't remember exact revno) function > `flet' was declared obsolete so Org-mode compilation is accompanied with > warnings about that. > > If just ignore them then I get malfunction Org-mode. I made patch to > change all `flet's to appropriate functions and it works. This should not happen if I understood Stefan correctly and you should log a bug against Emacs. > The problem is that these functions are new too. As I see it, the patch > will "break" compatability with current and older versions of Emacs. > > WDYT? Org needs to stay backwards compatible with older Emacs versions, so it will likely not be possible to directly replace things as you've done. I'm not sure a defsubst would cut it, so it looks like this will become another compatibility macro (expanding to either flet or cl-flet depending on Emacs version). Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Waldorf MIDI Implementation & additional documentation: http://Synth.Stromeko.net/Downloads.html#WaldorfDocs ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2012-07-26 14:35 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).