annotate lisp/prim/misc.el @ 138:6608ceec7cf8 r20-2b3

Import from CVS: tag r20-2b3
author cvs
date Mon, 13 Aug 2007 09:31:46 +0200
parents ac2d302a0011
children 3bb7ccffb0c0
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
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
22 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defun copy-from-above-command (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 "Copy characters from previous nonblank line, starting just above point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 Copy ARG characters, but not past the end of that line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 If no argument given, copy the entire rest of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 The characters copied are inserted in the buffer before point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (let ((cc (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (string ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (skip-chars-backward "\ \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (move-to-column cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; Default is enough to copy the whole rest of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (setq n (if arg (prefix-numeric-value arg) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; If current column winds up in middle of a tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; copy appropriate number of "virtual" space chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if (< cc (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (if (= (preceding-char) ?\t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (setq string (make-string (min n (- (current-column) cc)) ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (setq n (- n (min n (- (current-column) cc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; In middle of ctl char => copy that whole char.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (backward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (setq string (concat string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (min (save-excursion (end-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (+ n (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (insert string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; misc.el ends here