;;; zonkme.el ;;; ;;; Copyright (C) 2003, 2004, 2007, 2008 Thien-Thi Nguyen ;;; ;;; This file is part of ttn's personal elisp library, released under ;;; the terms of the GNU General Public License as published by the ;;; Free Software Foundation; either version 3, or (at your option) any ;;; later version. There is NO WARRANTY. See file COPYING for details. ;;; ;;; Description: Commands for editing zonkable `%load-path'-munging form. (defun zonkme-current-version () (let ((filename (shell-command-to-string (format "guile -c '(display %S)'" '(%search-load-path "ttn/VERSION")))) (orig-buf (current-buffer))) (with-temp-buffer (if (not (string= "#f" filename)) (insert-file-contents filename) (insert (shell-command-to-string (format "guile -c '%S %S'" '(use-modules (ttn METAINFO)) '(display (METAINFO (quote Version))))))) (substring (buffer-string) 0 -1)))) ;;;###autoload (defun insert-zonkme (v) "Insert a \"zonkme\" comment and `%load-path'-munging Scheme form. The comment says to zonk when version V of ttn-pers-scheme is installed. See also `scan-zonkme'." (interactive (list (read-string (format "(Current: %s) Version: " (zonkme-current-version))))) (when (string= "" v) (error "Must specify version")) (let ((standard-output (current-buffer))) (princ (format ";;;;;; zonkme-when-installed: ttn-pers-scheme-%s" v)) (print '(set! %load-path (cons "/home/ttn/build/ps" %load-path))))) ;;;###autoload (defun scan-zonkme () "Scan buffer for \"zonkme\" comments, and zonk them after confirmation. Use shell command: guile -c '(display (%search-load-path \"ttn/VERSION\"))' to find the name of the file that indicates the current installed version. Report the total found and zonked when done. See also `insert-zonkme'." (interactive) (let* ((version (zonkme-current-version)) (found 0) (count 0)) (save-excursion (goto-char (point-min)) (while (re-search-forward "^;+ zonkme.*scheme-\\(.*\\)$" (point-max) t) (let ((zonk-at (match-string 1))) (cond ((and (or (string= zonk-at version) (string-lessp zonk-at version)) (setq found (1+ found)) (y-or-n-p (format "zonk-at: %s, version: %s, zonk? " zonk-at version))) (beginning-of-line) (kill-line 2) (delete-blank-lines) (setq count (1+ count)))))) (if (and (= 0 found) (= 0 count)) (message "(gratuitous zonking avoided)") (message "(%d found %d zonked)" found count))))) (provide 'zonkme) ;;; zonkme.el ends here