comparison lisp/hyperbole/kotl/kotl-mode.el @ 114:8619ce7e4c50 r20-1b9

Import from CVS: tag r20-1b9
author cvs
date Mon, 13 Aug 2007 09:21:54 +0200
parents 4be1180a9e89
children
comparison
equal deleted inserted replaced
113:2ec2fe4a4c89 114:8619ce7e4c50
6 ;; KEYWORDS: data, hypermedia, outlines, wp 6 ;; KEYWORDS: data, hypermedia, outlines, wp
7 ;; 7 ;;
8 ;; AUTHOR: Bob Weiner & Kellie Clark 8 ;; AUTHOR: Bob Weiner & Kellie Clark
9 ;; 9 ;;
10 ;; ORIG-DATE: 6/30/93 10 ;; ORIG-DATE: 6/30/93
11 ;; LAST-MOD: 5-Dec-96 at 18:55:22 by Bob Weiner 11 ;; LAST-MOD: 6-Mar-97 at 01:15:42 by Bob Weiner
12 ;; 12 ;;
13 ;; This file is part of Hyperbole. 13 ;; This file is part of Hyperbole.
14 ;; Available for use and distribution under the same terms as GNU Emacs. 14 ;; Available for use and distribution under the same terms as GNU Emacs.
15 ;; 15 ;;
16 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. 16 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
155 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs. 155 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs.
156 (let ((indent (kcell-view:indent)) 156 (let ((indent (kcell-view:indent))
157 (opoint (point-marker)) 157 (opoint (point-marker))
158 (bocp) 158 (bocp)
159 start) 159 start)
160 (setq start (kotl-mode:beginning-of-line)) 160 (setq start (kotl-mode:start-of-line))
161 (if (setq bocp (kotl-mode:bocp)) 161 (if (setq bocp (kotl-mode:bocp))
162 (progn 162 (progn
163 ;; Add a temporary fill-prefix since this is the 1st line of the cell 163 ;; Add a temporary fill-prefix since this is the 1st line of the cell
164 ;; where label could interfere with centering. 164 ;; where label could interfere with centering.
165 (insert "\n\n") (insert-char ?\ indent))) 165 (insert "\n\n") (insert-char ?\ indent)))
520 ((integerp val) 520 ((integerp val)
521 (princ val (current-buffer))) 521 (princ val (current-buffer)))
522 ((and (markerp val) (marker-position val)) 522 ((and (markerp val) (marker-position val))
523 (princ (marker-position val) (current-buffer))) 523 (princ (marker-position val) (current-buffer)))
524 (t 524 (t
525 (error "Register '%c' does not contain text" register)))) 525 (error "Register `%c' does not contain text" register))))
526 (if (not arg) (exchange-point-and-mark))) 526 (if (not arg) (exchange-point-and-mark)))
527 527
528 (defun kotl-mode:just-one-space () 528 (defun kotl-mode:just-one-space ()
529 "Delete all spaces and tabs around point and leave one space." 529 "Delete all spaces and tabs around point and leave one space."
530 (interactive "*") 530 (interactive "*")
1294 "Move point to beginning of current or ARGth - 1 prior cell and return point." 1294 "Move point to beginning of current or ARGth - 1 prior cell and return point."
1295 (interactive "p") 1295 (interactive "p")
1296 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs. 1296 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs.
1297 (or arg (setq arg 1)) 1297 (or arg (setq arg 1))
1298 (or (integer-or-marker-p arg) 1298 (or (integer-or-marker-p arg)
1299 (error "(kotl-mode:beginning-of-cell): Wrong type arg, integer-or-marker, '%s'" arg)) 1299 (error "(kotl-mode:beginning-of-cell): Wrong type arg, integer-or-marker, `%s'" arg))
1300 (if (= arg 1) 1300 (if (= arg 1)
1301 (goto-char (kcell-view:start)) 1301 (goto-char (kcell-view:start))
1302 (kotl-mode:backward-cell (1- arg))) 1302 (kotl-mode:backward-cell (1- arg)))
1303 (point)) 1303 (point))
1304 1304
1309 "Move point to beginning of current or ARGth - 1 line and return point." 1309 "Move point to beginning of current or ARGth - 1 line and return point."
1310 (interactive "p") 1310 (interactive "p")
1311 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs. 1311 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs.
1312 (or arg (setq arg 1)) 1312 (or arg (setq arg 1))
1313 (or (integer-or-marker-p arg) 1313 (or (integer-or-marker-p arg)
1314 (error "(kotl-mode:start-of-line): Wrong type arg, integer-or-marker, '%s'" arg)) 1314 (error "(kotl-mode:start-of-line): Wrong type arg, integer-or-marker, `%s'" arg))
1315 (forward-line (1- arg)) 1315 (forward-line (1- arg))
1316 (if (eolp) 1316 (if (eolp)
1317 nil 1317 nil
1318 (forward-char (prog1 (kcell-view:indent) 1318 (forward-char (prog1 (kcell-view:indent)
1319 (beginning-of-line)))) 1319 (beginning-of-line))))
1320 (point)) 1320 (point))
1321 1321
1322 (defalias 'kotl-mode:beginning-of-line 'kotl-mode:start-of-line) 1322 ;;; This ensures that the key bound to `beginning-of-line' is replaced in
1323 ;;; kotl-mode.
1324 (fset 'kotl-mode:beginning-of-line 'kotl-mode:start-of-line)
1323 1325
1324 (defun kotl-mode:beginning-of-tree () 1326 (defun kotl-mode:beginning-of-tree ()
1325 "Move point to the level 1 root of the current cell's tree. 1327 "Move point to the level 1 root of the current cell's tree.
1326 Leave point at the start of the cell." 1328 Leave point at the start of the cell."
1327 (interactive) 1329 (interactive)
1367 "Move point to end of current or ARGth - 1 succeeding cell and return point." 1369 "Move point to end of current or ARGth - 1 succeeding cell and return point."
1368 (interactive "p") 1370 (interactive "p")
1369 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs. 1371 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs.
1370 (or arg (setq arg 1)) 1372 (or arg (setq arg 1))
1371 (or (integer-or-marker-p arg) 1373 (or (integer-or-marker-p arg)
1372 (error "(kotl-mode:end-of-cell): Wrong type arg, integer-or-marker, '%s'" arg)) 1374 (error "(kotl-mode:end-of-cell): Wrong type arg, integer-or-marker, `%s'" arg))
1373 (if (= arg 1) 1375 (if (= arg 1)
1374 (goto-char (kcell-view:end-contents)) 1376 (goto-char (kcell-view:end-contents))
1375 (kotl-mode:forward-cell (1- arg))) 1377 (kotl-mode:forward-cell (1- arg)))
1376 (point)) 1378 (point))
1377 1379
1382 "Move point to end of current or ARGth - 1 line and return point." 1384 "Move point to end of current or ARGth - 1 line and return point."
1383 (interactive "p") 1385 (interactive "p")
1384 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs. 1386 (setq zmacs-region-stays t) ;; Maintain region highlight for XEmacs.
1385 (or arg (setq arg 1)) 1387 (or arg (setq arg 1))
1386 (or (integer-or-marker-p arg) 1388 (or (integer-or-marker-p arg)
1387 (error "(kotl-mode:finish-of-line): Wrong type arg, integer-or-marker, '%s'" arg)) 1389 (error "(kotl-mode:finish-of-line): Wrong type arg, integer-or-marker, `%s'" arg))
1388 (forward-line (1- arg)) 1390 (forward-line (1- arg))
1389 (end-of-line) 1391 (end-of-line)
1390 ;; May have to move backwards to before label if support labels 1392 ;; May have to move backwards to before label if support labels
1391 ;; at end of cells. 1393 ;; at end of cells.
1392 (point)) 1394 (point))
1538 (setq arg (1- arg)))) 1540 (setq arg (1- arg))))
1539 (kotl-mode:backward-word (- arg))) 1541 (kotl-mode:backward-word (- arg)))
1540 (point)) 1542 (point))
1541 1543
1542 (defun kotl-mode:goto-cell (cell-ref &optional error-p) 1544 (defun kotl-mode:goto-cell (cell-ref &optional error-p)
1543 "Move point to start of cell given by CELL-REF. (See 'kcell:ref-to-id'.) 1545 "Move point to start of cell given by CELL-REF. (See `kcell:ref-to-id'.)
1544 Return point iff CELL-REF is found within current view. 1546 Return point iff CELL-REF is found within current view.
1545 With a prefix argument, CELL-REF is assigned the argument value for use 1547 With a prefix argument, CELL-REF is assigned the argument value for use
1546 as an idstamp. 1548 as an idstamp.
1547 1549
1548 Optional second arg, ERROR-P, non-nil means signal an error if CELL-REF is 1550 Optional second arg, ERROR-P, non-nil means signal an error if CELL-REF is
1552 (list (if current-prefix-arg 1554 (list (if current-prefix-arg
1553 (format "0%d" (prefix-numeric-value current-prefix-arg)) 1555 (format "0%d" (prefix-numeric-value current-prefix-arg))
1554 (read-string "Goto cell label or id: ")))) 1556 (read-string "Goto cell label or id: "))))
1555 (setq cell-ref 1557 (setq cell-ref
1556 (or (kcell:ref-to-id cell-ref) 1558 (or (kcell:ref-to-id cell-ref)
1557 (error "(kotl-mode:goto-cell): Invalid cell reference, '%s'" cell-ref))) 1559 (error "(kotl-mode:goto-cell): Invalid cell reference, `%s'" cell-ref)))
1558 (let* ((opoint (point)) 1560 (let* ((opoint (point))
1559 (found) 1561 (found)
1560 cell-id kvspec) 1562 cell-id kvspec)
1561 (if (= ?| (aref cell-ref 0)) 1563 (if (= ?| (aref cell-ref 0))
1562 ;; This is a standalone view spec, not a cell reference. 1564 ;; This is a standalone view spec, not a cell reference.
1587 (setq found (point))) 1589 (setq found (point)))
1588 ;; no match 1590 ;; no match
1589 (t (goto-char opoint) 1591 (t (goto-char opoint)
1590 nil)) 1592 nil))
1591 (if (and (not found) (or error-p (interactive-p))) 1593 (if (and (not found) (or error-p (interactive-p)))
1592 (error "(kotl-mode:goto-cell): No '%s' cell in this view" cell-ref) 1594 (error "(kotl-mode:goto-cell): No `%s' cell in this view" cell-ref)
1593 ;; Activate any viewspec associated with cell-ref. 1595 ;; Activate any viewspec associated with cell-ref.
1594 (if kvspec (kvspec:activate kvspec)))) 1596 (if kvspec (kvspec:activate kvspec))))
1595 found)) 1597 found))
1596 1598
1597 (defun kotl-mode:head-cell () 1599 (defun kotl-mode:head-cell ()
2247 existing-attributes)))))) 2249 existing-attributes))))))
2248 (beep)) 2250 (beep))
2249 (setq attribute (intern attribute) 2251 (setq attribute (intern attribute)
2250 value (kcell-view:get-attr attribute)) 2252 value (kcell-view:get-attr attribute))
2251 (if value 2253 (if value
2252 (setq value (read-expression 2254 (setq value (read-minibuffer
2253 (format "Change value of \"%s\" to: " attribute) 2255 (format "Change value of \"%s\" to: " attribute)
2254 (prin1-to-string value))) 2256 (prin1-to-string value)))
2255 (setq value (read-expression 2257 (setq value (read-minibuffer
2256 (format "Set value of \"%s\" to: " attribute)))) 2258 (format "Set value of \"%s\" to: " attribute))))
2257 (list attribute value nil))) 2259 (list attribute value nil)))
2258 (kcell-view:set-attr attribute value pos) 2260 (kcell-view:set-attr attribute value pos)
2259 ;; Note that buffer needs to be saved to store new attribute value. 2261 ;; Note that buffer needs to be saved to store new attribute value.
2260 (set-buffer-modified-p t) 2262 (set-buffer-modified-p t)
2556 (let ((bol (kotl-mode:start-of-line)) 2558 (let ((bol (kotl-mode:start-of-line))
2557 (eol (kotl-mode:finish-of-line))) 2559 (eol (kotl-mode:finish-of-line)))
2558 (prog1 2560 (prog1
2559 (buffer-substring bol eol) 2561 (buffer-substring bol eol)
2560 (delete-region bol eol))) 2562 (delete-region bol eol)))
2561 (error "(kotl-mode:delete-line): Invalid position, '%d'" (point))))) 2563 (error "(kotl-mode:delete-line): Invalid position, `%d'" (point)))))
2562 2564
2563 (defun kotl-mode:indent-line (arg) 2565 (defun kotl-mode:indent-line (arg)
2564 ;; Disallow the indent-line command. 2566 ;; Disallow the indent-line command.
2565 (error "(kotl-mode:indent-line): Insert spaces to indent each line.")) 2567 (error "(kotl-mode:indent-line): Insert spaces to indent each line."))
2566 2568
2617 (move-to-column (or goal-column temporary-goal-column)) 2619 (move-to-column (or goal-column temporary-goal-column))
2618 nil) 2620 nil)
2619 2621
2620 (defun kotl-mode:print-attributes (kview) 2622 (defun kotl-mode:print-attributes (kview)
2621 "Print to the `standard-output' stream the attributes of the current visible kcell. 2623 "Print to the `standard-output' stream the attributes of the current visible kcell.
2622 Takes argument KVIEW (so it can be used with 'kview:map-tree' and so that 2624 Takes argument KVIEW (so it can be used with `kview:map-tree' and so that
2623 KVIEW is bound correctly) but always operates upon the current view." 2625 KVIEW is bound correctly) but always operates upon the current view."
2624 ;; Move to start of visible cell to avoid printing attributes for an 2626 ;; Move to start of visible cell to avoid printing attributes for an
2625 ;; invisible kcell which point may be over. 2627 ;; invisible kcell which point may be over.
2626 ;; Print first line of cell for reference. 2628 ;; Print first line of cell for reference.
2627 (save-excursion 2629 (save-excursion