emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] org-babel and Xemacs incompatibilities


From: Michael Sperber
Subject: Re: [Orgmode] org-babel and Xemacs incompatibilities
Date: Mon, 07 Jun 2010 15:04:41 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) XEmacs/21.5-b29 (darwin)

"Eric Schulte" <address@hidden> writes:

>> And two more
>>
>>  o Symbol's function definition is void: assoc-default when trying to 
>> display an image
>> [...]
>>  o Symbol's function definition is void: make-temp-file when using 
>> org-babel-dot
>> [...]

Both of these are in XEmacs 21.5, but not 21.4.  As 21.4 is almost not
moving anymore, it may not be worth the effort to add them to 21.4.
(Volker would have to wait quite a while to get a 21.4 that works with
this.)  My suggestion is to leave org-mode and XEmacs 21.4 as is, and
for Volker to copy the definitions from 21.5 to his init.el.
(Attached.)  Is this acceptable?

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
(defun assoc-default (key alist &optional test default)
  "Find object KEY in a pseudo-alist ALIST.
ALIST is a list of conses or objects.  Each element (or the element's car,
if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY).
If that is non-nil, the element matches;
then `assoc-default' returns the element's cdr, if it is a cons,
or DEFAULT if the element is not a cons.

If no element matches, the value is nil.
If TEST is omitted or nil, `equal' is used."
  (let (found (tail alist) value)
    (while (and tail (not found))
      (let ((elt (car tail)))
        (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key)
          (setq found t value (if (consp elt) (cdr elt) default))))
      (setq tail (cdr tail)))
    value))


(defun make-temp-file (prefix &optional dir-flag suffix)
  "Create a temporary file.
The returned file name (created by appending some random characters at the
end of PREFIX, and expanding against the return value of `temp-directory' if
necessary), is guaranteed to point to a newly created empty file.  You can
then use `write-region' to write new data into the file.

If DIR-FLAG is non-nil, create a new empty directory instead of a file.

If SUFFIX is non-nil, add that at the end of the file name.

This function is analagous to mkstemp(3) under POSIX, avoiding the race
condition between testing for the existence of the generated filename (under
POSIX with mktemp(3), under Emacs Lisp with `make-temp-name') and creating
it."
  (let ((umask (default-file-modes))
        (temporary-file-directory (temp-directory))
        file)
    (unwind-protect
        (progn
          ;; Create temp files with strict access rights.  It's easy to
          ;; loosen them later, whereas it's impossible to close the
          ;; time-window of loose permissions otherwise.
          (set-default-file-modes #o700)
          (while (condition-case ()
                     (progn
                       (setq file
                             (make-temp-name
                              (expand-file-name prefix
                                                temporary-file-directory)))
                       (if suffix
                           (setq file (concat file suffix)))
                       (if dir-flag
                           (make-directory file)
                         (write-region "" nil file nil 'silent nil 'excl))
                       nil)
                   (file-already-exists t))
            ;; the file was somehow created by someone else between
            ;; `make-temp-name' and `write-region', let's try again.
            nil)
          file)
      ;; Reset the umask.
      (set-default-file-modes umask))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]