From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: hyperspec.el Date: 02 Apr 2002 13:30:33 -0500 Sender: emacs-devel-admin@gnu.org Message-ID: References: <200204011638.g31GcZM11145@aztec.santafe.edu> Reply-To: sds@gnu.org NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1017777287 11040 127.0.0.1 (2 Apr 2002 19:54:47 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 2 Apr 2002 19:54:47 +0000 (UTC) Cc: emacs-devel@gnu.org Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16sUMh-0002rx-00 for ; Tue, 02 Apr 2002 21:54:47 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16sUYU-00034l-00 for ; Tue, 02 Apr 2002 22:06:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16sT35-0003YU-00; Tue, 02 Apr 2002 13:30:27 -0500 Original-Received: from out012pub.verizon.net ([206.46.170.137] helo=out012.verizon.net) by fencepost.gnu.org with smtp (Exim 3.34 #1 (Debian)) id 16sT2W-0003R6-00; Tue, 02 Apr 2002 13:29:52 -0500 Original-Received: from gnu.org ([151.203.48.85]) by out012.verizon.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20020402182949.WLZX1346.out012.verizon.net@gnu.org>; Tue, 2 Apr 2002 12:29:49 -0600 Original-To: rms@gnu.org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Mail-Copies-To: never In-Reply-To: <200204011638.g31GcZM11145@aztec.santafe.edu> Original-Lines: 162 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2325 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2325 > * In message <200204011638.g31GcZM11145@aztec.santafe.edu> > * On the subject of "Re: hyperspec.el" > * Sent on Mon, 1 Apr 2002 09:38:35 -0700 (MST) > * Honorable Richard Stallman writes: > > Could you show me this file, please? appended I also suggest binding C-h C-s to `common-lisp-hyperspec' in lisp-mode. > the package is intended for viewing the CLHS (Common Lisp HyperSpec) > using browse-url. > > Could you show me a brief description (maybe 5 or 10 lines) of CLHS? > I don't recall having heard of it before. CLHS is an HTML version of the ANSI X3.226-1994: "American National Standard for Information Technology -- Programming Language -- Common Lisp" It was created by Kent Pittman, the X3J13 committee secretary, and is available from the Association of Lisp USERS (ALU, www.lisp.org). -- Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux Keep Jerusalem united! Read, think and remember! Cannot handle the fatal error due to a fatal error in the fatal error handler. ;;; clhs.el -- access the Common Lisp HyperSpec (CLHS) ;; Copyright (C) 2002 Free Software Foundation, Inc. ;; Author: Sam Steingold ;; Maintainer: FSF ;; Keywords: lisp ;; This file is a part of 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 (later Xanalys) 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. ;; This is inspired by the Erik Naggum's version of 1997. ;;; Code: (eval-when-compile (require 'cl)) ; push (require 'browse-url) (require 'thingatpt) (require 'url) (defcustom common-lisp-hyperspec-root "http://www.lisp.org/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/\"." :group 'lisp :type 'string :version "21.3") (defvar clhs-history nil "History of symbols looked up in the Common Lisp HyperSpec.") (defvar clhs-symbols nil) (defun clhs-table-buffer (&optional root) (unless root (setq root common-lisp-hyperspec-root)) (if (string-match "^file:/" root) (with-temp-buffer (insert-file-contents-literally (let* ((d (concat (substring root 5) "/Data/")) (f (concat d "Map_Sym.txt"))) (if (file-exists-p f) f (setq f (concat d "Symbol-Table.text")) (if (file-exists-p f) f (error "no symbol table at ~s" root)))) nil nil nil t) (goto-char 0) (current-buffer)) (let* ((d (concat root "/Data/")) (f (concat d "Map_Sym.txt"))) (set-buffer (url-retrieve-synchronously f)) (goto-char 0) (unless (looking-at "^HTTP/.*200 OK$") (kill-buffer (current-buffer)) (setq f (concat d "Symbol-Table.text")) (set-buffer (url-retrieve-synchronously f)) (goto-char 0) (unless (looking-at "^HTTP/.*200 OK$") (kill-buffer (current-buffer)) (error "no symbol table at ~s" root))) ;; skip to the first symbol (search-forward "\n\n") (current-buffer)))) (defun clhs-read-symbols () "read `clhs-symbols' from the current position in the current buffer" (while (not (eobp)) (puthash (buffer-substring-no-properties ; symbol (line-beginning-position) (line-end-position)) (progn (forward-line 1) ; file name (buffer-substring-no-properties ; strip "../" (+ 3 (line-beginning-position)) (line-end-position))) clhs-symbols) (forward-line 1))) (defun clhs-symbols () "Get `clhs-symbols' from `common-lisp-hyperspec-root'." (if (and clhs-symbols (not (= 0 (hash-table-count clhs-symbols)))) clhs-symbols (with-current-buffer (clhs-table-buffer) (unless clhs-symbols (setq clhs-symbols (make-hash-table :test 'equal :size 1031))) (clhs-read-symbols) (kill-buffer (current-buffer)) clhs-symbols))) (defun hash-table-complete (string table how) (let ((res nil) (st (upcase string)) (len (length string))) (maphash (lambda (key val) (when (and (<= len (length key)) (string= st (substring key 0 len))) (push key res))) table) (if how res ; `all-completions' (if (cdr res) (try-completion st (mapcar #'list res)) (if (string= st (car res)) t (car res)))))) ;;;###autoload (defun common-lisp-hyperspec (symbol-name) "Browse the Common Lisp HyperSpec documentation for SYMBOL-NAME. Finds the HyperSpec at `common-lisp-hyperspec-root'." (interactive (list (let ((sym (thing-at-point 'symbol))) (completing-read "Look-up symbol in the Common Lisp HyperSpec: " #'hash-table-complete (clhs-symbols) t sym 'clhs-history)))) (browse-url (concat common-lisp-hyperspec-root (gethash (upcase symbol-name) (clhs-symbols))))) (provide 'clhs)