gnu-emacs-sources
[Top][All Lists]
Advanced

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

some code and a question


From: Tom Wurgler
Subject: some code and a question
Date: Tue, 30 Dec 2003 10:02:28 -0500 (EST)

First, here is a couple of defadvices I wrote that I use a lot, hope someone
else can use 'em:

Normally, you can't write a buffer (or region) to a non-existent directory. This
code allows you to set the new variable `allow-writes-to-create-dirs' to
non-nil, then the dirs are created as needed using `make-directory'.

(defvar allow-writes-to-create-dirs nil
  "If t, user can do a write-file or write-region even to non-existing paths.
All non-existing parent dirs are created.")

(defadvice write-file (before check-dirname-file activate)
  "If `allow-writes-to-create-dirs', create any nonexistent parent dirs needed."
  (if (and allow-writes-to-create-dirs (file-name-directory filename))
      (let ((dir (file-name-directory filename)))
        (if (not (file-exists-p dir))
          (make-directory dir t)))))

(defadvice write-region (before check-dirname-region activate)
  "If `allow-writes-to-create-dirs', create any nonexistent parent dirs needed."
  (if allow-writes-to-create-dirs
      (let ((dir (file-name-directory filename)))
        (if (and dir (not (file-exists-p dir)))
          (make-directory dir t)))))

Secondly, anybody know of a package that would take as input an algebraic
expression and output the equivalent lisp code?

example:

covert

x = 2*y + cos(z)

into

(setq x (+ (* 2 y) (cos z)))

Thanks
tom






reply via email to

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