annotate lisp/prim/misc.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; misc.el --- miscellaneous functions for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1989 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (defun copy-from-above-command (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 "Copy characters from previous nonblank line, starting just above point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 Copy ARG characters, but not past the end of that line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 If no argument given, copy the entire rest of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 The characters copied are inserted in the buffer before point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (let ((cc (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (string ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (skip-chars-backward "\ \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (move-to-column cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Default is enough to copy the whole rest of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (setq n (if arg (prefix-numeric-value arg) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; If current column winds up in middle of a tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; copy appropriate number of "virtual" space chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if (< cc (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if (= (preceding-char) ?\t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq string (make-string (min n (- (current-column) cc)) ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (setq n (- n (min n (- (current-column) cc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; In middle of ctl char => copy that whole char.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (backward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (setq string (concat string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (min (save-excursion (end-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (+ n (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (insert string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; misc.el ends here