In article <lk8zcqolxo....@pc022.bln.elmeg.de>, "Nils Goesche"
<car...@cartan.de> wrote: > Hi! > Can somebody think of a more elegant way to do this: > (format nil "~@[~D~]~{+~D~}" (car lst) (cdr lst)) >where `lst' is a (possibly empty) > list of integers?
Elegance is in the eye of the beholder, you might find this more elegant: (format nil "~{~D~^+~}" lst)
> > Can somebody think of a more elegant way to do this: > > (format nil "~@[~D~]~{+~D~}" (car lst) (cdr lst)) > >where `lst' is a (possibly empty) list of integers?
> Elegance is in the eye of the beholder, you might find this more elegant: > (format nil "~{~D~^+~}" lst)
DARN! That's what I couldn't find. Thanks very much. Is this anywhere documented in the HyperSpec, BTW? All I can find is
# Finally, the ~^ directive can be used to terminate the iteration # prematurely.
in 22.3.7.4. Does that mean precisely the behavior of your example, that is, it will terminate prematurely iff the last element of the list has already been processed?
Regards, -- Nils Goesche "Don't ask for whom the <CTRL-G> tolls."
>> >where `lst' is a (possibly empty) list of integers? >> Elegance is in the eye of the beholder, you might find this more >> elegant: (format nil "~{~D~^+~}" lst) > DARN! That's what I couldn't find. Thanks very much. Is this anywhere > documented in the HyperSpec, BTW? All I can find is # Finally, the ~^ > directive can be used to terminate the iteration # prematurely. > in 22.3.7.4. Does that mean precisely the behavior of your example, > that is, it will terminate prematurely iff the last element of the list > has already been processed?
22.3.9.2 "Tilde Circumflex: Escape Upward" covers all you want to know, and more, about ~^. Basically, ~^ exits the loop if there are no more arguments.
> > >where `lst' is a (possibly empty) list of integers?
> > Elegance is in the eye of the beholder, you might find this more elegant: > > (format nil "~{~D~^+~}" lst)
> DARN! That's what I couldn't find. Thanks very much. Is this > anywhere documented in the HyperSpec, BTW? All I can find is
> # Finally, the ~^ directive can be used to terminate the iteration > # prematurely.
> in 22.3.7.4.
The CLHS index pre-version 5 doesn't well-index either format ops or # readmacros. You want version 5 or above. (If it has a gray background, you have a too-old version.)
To my knowledge, v5 is not downloadable directly from the Xanaly web site. Not sure why. The way to get it is to download the Personal Edition of Xanalys LispWorks (if you don't already have a Professional or Enterprise edition) and unpack the browsable documentation. That has a v5. I don't think they are trying to hide it there--probably just no one ever got around to updating the web site.
v5 has very few other differences from v3. It doesn't have the little java widget that prompts for a symbol name though. There were too many reports of browsers not handling that correctly, so the widget was removed. You have to click through to where you want, which I find is mostly just as fast as typing, even for me who types fast.
> > where `list' is a (possibly empty) list of integers.
> Yes, yes. I know there are seperate function and value slots in > symbols; but using them like this still frightens me...
Try to overcome that fear. It will be worth it. And trust me on the sun-screen...
Regs, Pierre.
-- Pierre R. Mai <p...@acm.org> http://www.pmsf.de/pmai/ The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. -- Nathaniel Borenstein
> > > Elegance is in the eye of the beholder, you might find this more elegant: > > > (format nil "~{~D~^+~}" lst)
> > DARN! That's what I couldn't find. Thanks very much. Is this > > anywhere documented in the HyperSpec, BTW? All I can find is
> > # Finally, the ~^ directive can be used to terminate the iteration > > # prematurely.
> > in 22.3.7.4.
> The CLHS index pre-version 5 doesn't well-index either format ops or > # readmacros. You want version 5 or above. (If it has a gray background, > you have a too-old version.)
Thanks, got it. Unfortunately, hyperspec-naggum.el from ILISP doesn't work with the new CLHS anymore. (fun_format.htm is now named f_format.htm, for instance). Has anybody made a new version of hyperspec-naggum.el that works with the new version?
"Tim Moore" <mo...@bricoworks.com> writes: > 22.3.9.2 "Tilde Circumflex: Escape Upward" covers all you want to > know, and more, about ~^. Basically, ~^ exits the loop if there are > no more arguments.
Actually, I would have found it if I had not forgotten that `Circumflex' is the name of the ^ character :-)
Regards, -- Nils Goesche "Don't ask for whom the <CTRL-G> tolls."
Nils Goesche <car...@cartan.de> writes: > Kent M Pitman <pit...@world.std.com> writes:
> > The CLHS index pre-version 5 doesn't well-index either format ops > > or # readmacros. You want version 5 or above. (If it has a gray > > background, you have a too-old version.)
> Thanks, got it. Unfortunately, hyperspec-naggum.el from ILISP > doesn't work with the new CLHS anymore. (fun_format.htm is now > named f_format.htm, for instance). Has anybody made a new version > of hyperspec-naggum.el that works with the new version?
Until I read Mr. Pitman's note above, I didn't know that there were significant differences between the CLHS versions (except for the background color... :)
I include a quick fix with this article (see below). It works on my laptop (Emacs 21.1, ILISP 5.11.1 from CVS I think, plus CLHS from LispWorks for Linux Personal Edition). Bear with me if it's ugly, grossly inefficient, or if it simply doesn't work with your setup. I just hacked it together, and I'm not at all an Emacs Lisp wizard.
(Credits go to Daniel Barlow. I had to look at his version to find out that such thing as a symbol table for the CLHS existed.)
HTH, Edi.
;;; hyperspec.el --- Browse documentation from the Common Lisp HyperSpec
;; Copyright 1997 Naggum Software
;; Author: Erik Naggum <e...@naggum.no> ;; Keywords: lisp
;; This file is not part of GNU Emacs, but distributed under the same ;; conditions as GNU Emacs, and is useless without GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Kent Pitman and the Harlequin Group have made the text of American ;; National Standard for Information Technology -- Programming Language -- ;; Common Lisp, ANSI X3.226-1994 available on the WWW, in the form of the ;; Common Lisp HyperSpec. This package makes it convenient to peruse this ;; documentation from within Emacs.
;;; Code:
(require 'cl) (require 'browse-url) ;you need the Emacs 20 version (require 'thingatpt)
(defvar common-lisp-hyperspec-root "http://www.xanalys.com/software_tools/reference/HyperSpec/" "The root of the Common Lisp HyperSpec URL. If you copy the HyperSpec to your local system, set this variable to something like \"file:/usr/local/doc/HyperSpec/\".")
(defvar common-lisp-hyperspec-symbol-table "/usr/local/lib/LispWorksPersonal/lib/4-1-0-0/manual/online/web/CLHS/Data/M ap_Sym.txt" "The HyperSpec symbol table file. Must be a local file.")
(defvar common-lisp-hyperspec-history nil "History of symbols looked up in the Common Lisp HyperSpec.")
;;if only we had had packages or hash tables..., but let's fake it.
(defun common-lisp-hyperspec (symbol-name) "View the documentation on SYMBOL-NAME from the Common Lisp HyperSpec. If SYMBOL-NAME has more than one definition, all of them are displayed with your favorite browser in sequence. The browser should have a \"back\" function to view the separate definitions.
The Common Lisp HyperSpec is the full ANSI Standard Common Lisp, provided by Kent Pitman and the Harlequin Group. By default, the Harlequin WWW site is visited to retrieve the information. The Harlequin Group allows you to transfer the entire Common Lisp HyperSpec to your own site under certain conditions. Visit http://www.harlequin.com/books/HyperSpec/ for more information. If you copy the HyperSpec to another location, customize the variable `common-lisp-hyperspec-root' to point to that location." (interactive (list (let ((symbol-at-point (thing-at-point 'symbol))) (if (and symbol-at-point (intern-soft (downcase symbol-at-point) common-lisp-hyperspec-symbols)) symbol-at-point (completing-read "Look up symbol in Common Lisp HyperSpec: " common-lisp-hyperspec-symbols #'boundp t symbol-at-point 'common-lisp-hyperspec-history))))) (maplist (lambda (entry) (browse-url (concat common-lisp-hyperspec-root "Body/" (car entry))) (if (cdr entry) (sleep-for 1.5))) (let ((symbol (intern-soft (downcase symbol-name) common-lisp-hyperspec-symbols))) (if (and symbol (boundp symbol)) (symbol-value symbol) (error "The symbol `%s' is not defined in Common Lisp" symbol-name)))))
;;; Added the following just to provide a common entry point according ;;; to the various 'hyperspec' implementations. ;;; ;;; 19990820 Marco Antoniotti
Nils Goesche <car...@cartan.de> writes: > Kent M Pitman <pit...@world.std.com> writes:
> > The CLHS index pre-version 5 doesn't well-index either format ops or > > # readmacros. You want version 5 or above. (If it has a gray background, > > you have a too-old version.)
> Thanks, got it. Unfortunately, hyperspec-naggum.el from ILISP doesn't > work with the new CLHS anymore. (fun_format.htm is now named > f_format.htm, for instance). Has anybody made a new version of > hyperspec-naggum.el that works with the new version?
Does it have the data file literally included into it? It should load it dynamically from the data directory, then it would compatibly see the updates. It should look for either the short filename or the long filename, though; I had no choice but to change the name in order to keep filenames DOS compliant (i.e., compatible with the least common denominator file system I could imagine, so no one would bother me more about file system non-compliances).
In v5 and above, the Data dir contains these files:
Map_IssW.txt Map_IssX.txt Map_Sym.txt
I presume Erik's package cares mostly about the last one.
Keeping compatibility with earlier versions by having it also look for the older, longer filenames (the names of which I don't have access to on this computer I'm typeing to at the moment) seems worthwhile.
> > > The CLHS index pre-version 5 doesn't well-index either format > > > ops or # readmacros. You want version 5 or above. (If it has a > > > gray background, you have a too-old version.)
> > Thanks, got it. Unfortunately, hyperspec-naggum.el from ILISP > > doesn't work with the new CLHS anymore. (fun_format.htm is now > > named f_format.htm, for instance). Has anybody made a new version > > of hyperspec-naggum.el that works with the new version?
> Does it have the data file literally included into it?
* Kent M Pitman | Does it have the data file literally included into it?
I found no such thing in the version for which I wrote this package.
/// -- The past is not more important than the future, despite what your culture has taught you. Your future observations, conclusions, and beliefs are more important to you than those in your past ever will be. The world is changing so fast the balance between the past and the future has shifted.
> > > The CLHS index pre-version 5 doesn't well-index either format > > > ops or # readmacros. You want version 5 or above. (If it has a > > > gray background, you have a too-old version.)
> > Thanks, got it. Unfortunately, hyperspec-naggum.el from ILISP > > doesn't work with the new CLHS anymore. (fun_format.htm is now > > named f_format.htm, for instance). Has anybody made a new version > > of hyperspec-naggum.el that works with the new version?
If you're like me and you dig the KDE web/file browser for its "Web Shortcuts" (like 'ggg:split-sequence' for a Google Group Search), here's another quickie:
If you have a current version of LispWorks (or another local copy of the CLHS), cd to the directory where the CLHS symbol table is located. On my machine (LispWorks for Linux Personal Edition 4.1.20) the file you're looking for is "Map_Sym.txt" and the directory is "/usr/local/lib/LispWorksPersonal/lib/4-1-0-0/manual/online/web/CLHS/Data/" .
Start the little Perl script below with Map_Sym.txt redirected to stdin, i.e. something like './clhs.pl < Map_Sym.txt'.
Now you can start KDEs Konqueror, open its settings and add a new 'Web Shortcut', something like:
> I include a quick fix with this article (see below).
Er, here's an improved version. It was too late yesterday... :)
Edi.
;;; hyperspec.el --- Browse documentation from the Common Lisp HyperSpec
;; Copyright 1997 Naggum Software
;; Author: Erik Naggum <e...@naggum.no> ;; Keywords: lisp
;; This file is not part of GNU Emacs, but distributed under the same ;; conditions as GNU Emacs, and is useless without GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Kent Pitman and the Harlequin Group have made the text of American ;; National Standard for Information Technology -- Programming Language -- ;; Common Lisp, ANSI X3.226-1994 available on the WWW, in the form of the ;; Common Lisp HyperSpec. This package makes it convenient to peruse this ;; documentation from within Emacs.
;;; Code:
(require 'cl) (require 'browse-url) ;you need the Emacs 20 version (require 'thingatpt)
(defvar common-lisp-hyperspec-root "http://www.xanalys.com/software_tools/reference/HyperSpec/" "The root of the Common Lisp HyperSpec URL. If you copy the HyperSpec to your local system, set this variable to something like \"file:/usr/local/doc/HyperSpec/\".")
;;; Added variable for CLHS symbol table. See details below. ;;; ;;; 20011201 Edi Weitz
(defvar common-lisp-hyperspec-symbol-table "/usr/local/lib/LispWorksPersonal/lib/4-1-0-0/manual/online/web/CLHS/Data/M ap_Sym.txt" "The HyperSpec symbol table file. Must be a local file.")
(defvar common-lisp-hyperspec-history nil "History of symbols looked up in the Common Lisp HyperSpec.")
;;if only we had had packages or hash tables..., but let's fake it.
;;; Removed facility for multiple definition because the symbol table ;;; has only one entry per SYMBOL-NAME ;;; ;;; 20011201 Edi Weitz
(defun common-lisp-hyperspec (symbol-name) "View the documentation on SYMBOL-NAME from the Common Lisp HyperSpec.
The Common Lisp HyperSpec is the full ANSI Standard Common Lisp, provided by Kent Pitman and the Harlequin Group. By default, the Harlequin WWW site is visited to retrieve the information. The Harlequin Group allows you to transfer the entire Common Lisp HyperSpec to your own site under certain conditions. Visit http://www.harlequin.com/books/HyperSpec/ for more information. If you copy the HyperSpec to another location, customize the variable `common-lisp-hyperspec-root' to point to that location." (interactive (list (let ((symbol-at-point (thing-at-point 'symbol))) (if (and symbol-at-point (intern-soft (downcase symbol-at-point) common-lisp-hyperspec-symbols)) symbol-at-point (completing-read "Look up symbol in Common Lisp HyperSpec: " common-lisp-hyperspec-symbols #'boundp t symbol-at-point 'common-lisp-hyperspec-history))))) (browse-url (concat common-lisp-hyperspec-root "Body/" (let ((symbol (intern-soft (downcase symbol-name) common-lisp-hyperspec-symbols))) (if (and symbol (boundp symbol)) (symbol-value symbol) (error "The symbol `%s' is not defined in Common Lisp" symbol-name))))))
;;; Added the following just to provide a common entry point according ;;; to the various 'hyperspec' implementations. ;;; ;;; 19990820 Marco Antoniotti
On Sat, 1 Dec 2001 00:58:08 GMT, Kent M Pitman <pit...@world.std.com> wrote:
> Nils Goesche <car...@cartan.de> writes: [...] > > Thanks, got it. Unfortunately, hyperspec-naggum.el from ILISP doesn't > > work with the new CLHS anymore. (fun_format.htm is now named [...] > Does it have the data file literally included into it? It should load
The ILISP distribution comes with the following HyperSpec lookup tools in the `extra' directory: