Source

hyperbole / kotl / klabel.el

Diff from to

File kotl/klabel.el

-;;!emacs
-;;
-;; FILE:         klabel.el
-;; SUMMARY:      Display label handling for koutlines.
-;; USAGE:        GNU Emacs Lisp Library
-;; KEYWORDS:     outlines, wp
-;;
-;; AUTHOR:       Bob Weiner
-;; ORG:          BeOpen.com
-;;
-;; ORIG-DATE:    17-Apr-94
-;; LAST-MOD:     15-Jul-99 at 10:36:47 by Bob Weiner
-;;
-;; Copyright (C) 1994-1999  BeOpen.com
-;; See the "../HY-COPY" file for license information.
-;;
-;; This file is part of Hyperbole.
+;;; klabel.el --- Display label handling for koutlines.
 
-;;; ************************************************************************
+;; Copyright (C)  Free Software Foundation, Inc.
+;; Developed with support from Motorola Inc.
+
+;; Author: Bob Weiner, Brown U.
+;;         Kellie Clark
+;; Maintainer: Mats Lidell <matsl@contactor.se>
+;; Keywords: outlines, wp
+
+;; This file is part of GNU Hyperbole.
+
+;; GNU Hyperbole 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 Hyperbole 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., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;;; Code:
+
+;;;
 ;;; Public variables
-;;; ************************************************************************
+;;;
 
 (defvar klabel-type:changing-flag nil
   "Non-nil only while the label type in the current view is being changed.")
 
-;;; ************************************************************************
+;;;
 ;;; Public functions
-;;; ************************************************************************
+;;;
 
 ;;;
 ;;; klabel - koutline display labels
 	  ((eq label-type 'partial-alpha)
 	   (error
 	    "(klabel:level): Can't compute the level of a partial-alpha label"))
-	  (t (error "(klabel:level): Invalid label type setting: `%s'"
+	  (t (error "(klabel:level): Invalid label type setting: '%s'"
 		    label-type)))))
 
 (defun klabel:parent (label)
 	    (error
 	     "(klabel:child-id): Can't compute child of idstamp label"))))
 	(t (error
-	    "(klabel-type:child): Invalid label type setting: `%s'"
+	    "(klabel-type:child): Invalid label type setting: '%s'"
 	    label-type))))
 
 (defun klabel-type:increment (label-type)
 		(error "(klabel:increment-no): 0 cell cannot have a sibling")
 	      (error "(klabel:increment-id): Can't compute sibling of idstamp label")))))
 	(t (error
-	    "(klabel:increment): Invalid label type setting: `%s'"
+	    "(klabel:increment): Invalid label type setting: '%s'"
 	    label-type))))
 
 (defun klabel-type:parent (label-type)
 	    (error
 	     "(klabel:parent-id): Can't compute parent of idstamp label"))))
 	(t (error
-	    "(klabel-type:parent): Invalid label type setting: `%s'"
+	    "(klabel-type:parent): Invalid label type setting: '%s'"
 	    label-type))))
 
 ;;;
 ;;; partial-alpha klabels
 ;;;
 
-(defalias 'klabel:child-partial-alpha 'kotl-label:child)
+(fset 'klabel:child-partial-alpha 'kotl-label:child)
 
 (defun klabel:increment-partial-alpha (label)
   "Increment partial alpha LABEL by one and return."
 	 (concat (substring label 0 (match-beginning 0))
 		 (int-to-string
 		  (1+ (string-to-int (substring label (match-beginning 0)))))))
-	(t (error "(klabel:increment-legal): Invalid label, `%s'" label))))
+	(t (error "(klabel:increment-legal): Invalid label, '%s'" label))))
 
 (defun klabel:level-legal (label)
   "Return outline level as an integer of legal-style LABEL.
 	  (level 1)
 	  (len (length label)))
       (while (< i len)
-	(if (eq (aref label i) ?.)
+	(if (= (aref label i) ?.)
 	    (setq level (1+ level)))
 	(setq i (1+ i)))
       level)))
 ;; It must be one of the following symbols:
 ;;   no              for no labels,
 ;;   id              for permanent idstamp labels, e.g. 001, 002, etc.
-;;   alpha           for `1a2' full alphanumeric labels
-;;   legal           for `1.1.2' labels
-;;   partial-alpha   for partial alphanumeric labels, e.g. `2' for node `1a2'
-;;   star            for multi-star labeling, e.g. `***'.
+;;   alpha           for '1a2' full alphanumeric labels
+;;   legal           for '1.1.2' labels
+;;   partial-alpha   for partial alphanumeric labels, e.g. '2' for node '1a2'
+;;   star            for multi-star labeling, e.g. '***'.
 
 ;;
 ;; Functions to compute sibling and child labels for particular label types.
 	(concat (substring prev-label 0 last-part) next)))))
 
 (defun klabel-type:to-label-end (&optional label-type)
-  "Return function which will search backward to the end of a cell's label.
+  "Return function which will search backward to a the end of a cell's label.
 Label format is optional LABEL-TYPE or the default label type for the current view.
 
 Function signature is: ().  It takes no arguments and begins the search from point."
 		   (function
 		    (lambda ()
 		      (if (re-search-backward
-			   "\\(\\`\\|[\n\r\^_][\n\r]\\)[ \t]*[1-9][0-9a-zA-Z]*"
+			   "\\(\\`\\|[\n\r][\n\r]\\)[ \t]*[1-9][0-9a-zA-Z]*"
 			   nil t)
 			  (goto-char (match-end 0))))))
 		  (cons
 		   (function
 		    (lambda ()
 		      (if (re-search-backward
-			   "\\(\\`\\|[\n\r\^_][\n\r]\\)[ \t]*[0-9]+\\(\\.[0-9]+\\)*"
+			   "\\(\\`\\|[\n\r][\n\r]\\)[ \t]*[0-9]+\\(\\.[0-9]+\\)*"
 			   nil t)
 			  (goto-char (match-end 0))))))
 		    (cons
 		     (function
 		      (lambda ()
 			(if (re-search-backward
-			     "\\(\\`\\|[\n\r\^_][\n\r]\\)[ \t]*\\*+" nil t)
+			     "\\(\\`\\|[\n\r][\n\r]\\)[ \t]*\\*+" nil t)
 			    (goto-char (match-end 0))))))
 		    (cons
 		     'no
 			 (if (and (not hyperb:xemacs-p)
 				  (string-lessp emacs-version "19.22"))
 			     (kproperty:previous-single-change (point) 'kcell)
-			   ;; (GNU Emacs V19.22 / XEmacs V19.9) or greater
+			   ;; (GNU Emacs V19.22 / Lucid Emacs V19.9) or greater
 			   (- (kproperty:previous-single-change
 			       (point) 'kcell) 1))))))
 		    (cons
 		     (function
 		      (lambda ()
 			(if (re-search-backward
-			     "\\(\\`\\|[\n\r\^_][\n\r]\\)[ \t]*[0-9]+\\|[a-zA-Z]+"
+			     "\\(\\`\\|[\n\r][\n\r]\\)[ \t]*[0-9]+\\|[a-zA-Z]+"
 			     nil t)
 			    (goto-char (match-end 0))))))
 		    (cons
 		     (function
 		      (lambda ()
 			(if (re-search-backward
-			     "\\(\\`\\|[\n\r\^_][\n\r]\\)[ \t]*0[0-9]+" nil t)
+			     "\\(\\`\\|[\n\r][\n\r]\\)[ \t]*0[0-9]+" nil t)
 			    (goto-char (match-end 0)))))))))
-	(error "(kview:to-label-end): Invalid label type: `%s'" label-type)))
+	(error "(kview:to-label-end): Invalid label type: '%s'" label-type)))
 
 (defun klabel-type:star-label (prev-label &optional child-p)
   "Return full star label, e.g. ***, for cell following PREV-LABEL's cell.
 		  ((eq label-type 'no) "")
 		  ((eq label-type 'star) "*")
 		  (t (error
-		      "(klabel-type:set-labels): Invalid label type: `%s'"
+		      "(klabel-type:set-labels): Invalid label type: '%s'"
 		      label-type))))
       (let ((klabel-type:changing-flag t))
 	(klabel-type:update-labels-from-point label-type first-label)))))
 is signaled."
   (if (not (kotl-label:is-p label))
       (error
-       "(kotl-label:increment): First arg, `%s', must be a kotl-label."
+       "(kotl-label:increment): First arg, '%s', must be a kotl-label."
        label))
   (let ((int-p) (val 0))
     (if (or (setq int-p (kotl-label:integer-p label))
 	    (progn (setq int-p (string-to-int label))
 		   (if (> (setq val (+ int-p n)) 0)
 		       (kotl-label:create val)
-		     (error "(kotl-label:increment): Decrement of `%s' by `%d' is less than 1." label n)))
+		     (error "(kotl-label:increment): Decrement of '%s' by '%d' is less than 1." label n)))
 	  ;; alpha-p
 	  (if (<= 0 (setq val (+ n (kotl-label:alpha-to-int label))))
 	      (kotl-label:create
 	       (kotl-label:int-to-alpha val))
-	    (error "(kotl-label:increment): Decrement of `%s' by `%d' is illegal." label n)))
-      (error "(kotl-label:increment): label, `%s', must be all digits or alpha characters" label))))
+	    (error "(kotl-label:increment): Decrement of '%s' by '%d' is illegal." label n)))
+      (error "(kotl-label:increment): label, '%s', must be all digits or alpha characters" label))))
 
 (defun kotl-label:increment-alpha (label)
   "Return alphabetic LABEL incremented by 1.
 
 
 
-;;; ************************************************************************
+;;;
 ;;; Private functions
-;;; ************************************************************************
+;;;
 
 (defun klabel:set (new-label &optional label-sep-len)
   "Replace label displayed in cell at point with NEW-LABEL, which may be a different label type.
 For example, the full label \"1a2\" has kotl-label \"2\", as does \"1.1.2\"."
   (if (string-match "[0-9]+$\\|[a-zA-Z]+$" label)
       (substring label (match-beginning 0))
-    (error "(klabel:to-kotl-label): Invalid label, `%s'" label)))
+    (error "(klabel:to-kotl-label): Invalid label, '%s'" label)))
 
 (defun klabel-type:update-labels-from-point (label-type first-label)
   (let ((label-sep-len (kview:label-separator-length kview)))
      1.423477662509912))
 
 (provide 'klabel)
+
+;;; klabel.el ends here