davis@scr.slb.com (Paul Davis) (04/27/89)
Some functions I have around me all the time, the interactive ones bound to function keys. enjoy, Paul --- cut here --- ;;; Copyright (C) Schlumberger Cambridge Research, 1989 ;;; subject to the terms of the GNU general public licence ;;; library file for miscellaneous interactive functions (defun backward-kill-line () "Kills the line *left* of point, rather than right of it" (interactive) (setq end (point)) (beginning-of-line 1) (kill-region (point) end)) (defun kill-to-top () "Kill region between point and top of buffer" (interactive) (kill-region (point-min) (point))) (defun kill-to-bottom () "Kill region between point and end-of-buffer" (interactive) (kill-region (point) (point-max))) (defun bind-macro (key) "Bind the last macro to a key, locally" (interactive "kBind macro to key:") (name-last-kbd-macro 'this-macro) (local-set-key key 'this-macro)) ;;; Emacs Lisp library (non-interactive) ;;; Paul Davis (defun strip-white-space (string) "Return STRING stripped of surrounding white-space" (substring string (string-match "[^ ]" string) (string-match "[ ]*$" string))) (defun scar (string) "Like car, but for space-separated substrings. Leading and trailing blank space on the string is ignored" (if (string-match "\\(\\s +\\|\n\\)" string) (if (= (match-beginning 0) 0) (scar (substring string (match-end 0))) (substring string 0 (match-beginning 0))) string)) (defun scdr (string) "Like cdr, but for space-separated substrings. Leading and trailing white space on the string is ignored." (if (string-match "\\(\\s +\\|\n\\)" string) (if (= (match-end 0) (length string)) (substring string 0 (match-beginning 0)) (substring string (match-end 0))) "")) (defun resolve-string (string) "Return a list of strings where each element is an item of STRING. Items are space-separated in STRING." (cond ((= (length string) 0) nil) (t (cons (scar string) (resolve-string (scdr string)))))) (defun expand-path-names (path) (cond ((null path) nil) (t (cons (expand-file-name (car path)) (expand-path-names (cdr path)))))) (defun pop-this-file (path file) "Return PATH with FILE as first component." (setq new-path (strip-this-file path file)) (cons file new-path)) (defun strip-this-file (path file) "Return PATH without FILE as a component" (cond ((null path)) ((string= (car path) file) (cdr path)) (t (cons (car path) (strip-this-file (cdr path) file))))) (defun file-type-match (file-name file-type) "Return true if there is a terminating substring of file-name preceded by a `.' and that matches file-type" (interactive "sFilename: \nsfiletype:") (if (eq nil (setq suffx-ndx (string-match "\\." file-name nil))) nil (equal file-type (substring file-name (+ suffx-ndx 1) nil))))