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