From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: John H Swaby Newsgroups: gmane.emacs.bugs Subject: Sesquicolon -- Note: Not a Bug Date: Fri, 23 Aug 2002 00:10:55 -0600 (MDT) Sender: bug-gnu-emacs-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Trace: main.gmane.org 1030083059 16504 127.0.0.1 (23 Aug 2002 06:10:59 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 23 Aug 2002 06:10:59 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17i7er-0004I3-00 for ; Fri, 23 Aug 2002 08:10:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17i7g4-0004QO-00; Fri, 23 Aug 2002 02:12:12 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17i7f3-0004DG-00 for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2002 02:11:09 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17i7f0-0004Cv-00 for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2002 02:11:08 -0400 Original-Received: from endeavour.uwyo.edu ([129.72.10.25]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17i7ev-0004Ch-00 for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2002 02:11:01 -0400 Original-Received: from CONVERSION-DAEMON.endeavour.uwyo.edu by endeavour.uwyo.edu (PMDF V6.1-1 #40460) id <0H1A00J019687W@endeavour.uwyo.edu> for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2002 00:10:56 -0600 (MDT) Original-Received: from asuwlink.uwyo.edu (asuwlink.uwyo.edu [129.72.60.2]) by endeavour.uwyo.edu (PMDF V6.1-1 #40460) with ESMTP id <0H1A00GDC968M5@endeavour.uwyo.edu> for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2002 00:10:56 -0600 (MDT) Original-Received: from localhost (polymath@localhost) by asuwlink.uwyo.edu (8.8.8+Sun/8.8.8) with ESMTP id AAA06720 for ; Fri, 23 Aug 2002 00:10:56 -0600 (MDT) Original-To: bug-gnu-emacs@gnu.org X-Authentication-warning: asuwlink.uwyo.edu: polymath owned process doing -bs Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:3285 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:3285 Dear Emacs Maintainers: I teach a Unix scripting and commands class where I present scripting in Emacs Lisp along with Perl, Python, and Tcl scripting. For the languages other than Emacs Lisp, we use the shebang, "#!", as the first two characters of our scripts; but since Emacs requires more than two arguments to load and run a script in batch mode, I use the sesquicolon, ":;", for Emacs. I have not seen anything written about this, so I thought (if it is new) you may find it of interest. To illustrate, here are two example scripts (I say a little more after the listing of the scripts): :;exec emacs -batch -l $0 -f : $* # -*- Emacs-Lisp -*- ;;; Anagram (permute the characters of) the command line arguments (defun : () (random t) (print-string-list (mapcar 'anagram command-line-args-left))) (defun print-string-list (ls) (cond (ls (princ (format (if (cdr ls) "%s " "%s\n") (car ls))) (print-string-list (cdr ls))))) (defun anagram (str) (if (zerop (length str)) str (let ((n (random (length str)))) (concat (substring str n (1+ n)) (anagram (concat (substring str 0 n) (substring str (1+ n)))))))) ;;; end of anagram :;exec emacs -batch -l $0 -f : $* # -*- Emacs-Lisp -*- ;;; Determine the kinship relationship between two files (need absolute paths) (defun : () (let ((args command-line-args-left)) (cond ((< (length args) 2) (princ (format "Usage: %s path1 path2\n" (file-name-nondirectory (nth 2 command-line-args)))) (kill-emacs 1))) (set 'r (relate (split-string (nth 0 args) "/") (split-string (nth 1 args) "/"))) (if (= (set 'rel (car r)) 1) (princ "siblings") (if (> rel 1) (princ (format "order %d cousins" (1- rel))))) (if (> (set 'rem (cdr r)) 0) (princ (concat (if (> rel 0) " ") (format "removed by %d\n" rem))) (if (> rel 0) (terpri))))) (defun relate (r1 r2) (if (and r1 r2 (equal (car r1) (car r2))) (relate (cdr r1) (cdr r2)) (cons (min (length r1) (length r2)) (abs (- (length r1) (length r2)))))) ;;; end of kinship If the Bourne shell or Bash is running the above scripts and Emacs is of a recent vintage, then the above scripts are fine. If, however, the Korn shell ends up initially executing the above scripts, then $0 should be changed to $_. To cover your (portable) bases, do this for the first two lines: :;f=$0;if [ $_ ];then f=$_;fi :;exec emacs -batch -l $f -f : $* # -*- Emacs-Lisp -*- Current versions of Emacs define the colon, ":", as a constant equal to a colon; however, older emacsen, do not (for example version 19.30). So for an older Emacs, change the sesquicolon-exec line in the script to include "-eval '(setq : t)'". Something like this: :;exec emacs -batch -eval '(setq : t)' -l $0 -f : $* I want to thank all of the maintainers for their work on the E xtensible M odifiable A lgorithmic C omputer S ystem You've made Lisp readily available to the world! Sincerely, John H. Swaby polymath@uwyo.edu