Mercurial > emacs
annotate lisp/misc.el @ 746:1b0748ff6f65
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 07 Jul 1992 00:45:18 +0000 |
parents | 505130d1ddf8 |
children | 4f28bd14272c |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
1 ;;; misc.el --- basic editing commands for Emacs |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
2 |
35 | 3 ;; Copyright (C) 1989 Free Software Foundation, Inc. |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 1, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
21 | |
22 (defun copy-from-above-command (&optional arg) | |
23 "Copy characters from previous nonblank line, starting just above point. | |
24 Copy ARG characters, but not past the end of that line. | |
25 If no argument given, copy the entire rest of the line. | |
26 The characters copied are inserted in the buffer before point." | |
27 (interactive "P") | |
28 (let ((cc (current-column)) | |
29 n | |
30 (string "")) | |
31 (save-excursion | |
32 (beginning-of-line) | |
33 (backward-char 1) | |
34 (skip-chars-backward "\ \t\n") | |
35 (move-to-column cc) | |
36 ;; Default is enough to copy the whole rest of the line. | |
37 (setq n (if arg (prefix-numeric-value arg) (point-max))) | |
38 ;; If current column winds up in middle of a tab, | |
39 ;; copy appropriate number of "virtual" space chars. | |
40 (if (< cc (current-column)) | |
41 (if (= (preceding-char) ?\t) | |
42 (progn | |
43 (setq string (make-string (min n (- (current-column) cc)) ?\ )) | |
44 (setq n (- n (min n (- (current-column) cc))))) | |
45 ;; In middle of ctl char => copy that whole char. | |
46 (backward-char 1))) | |
47 (setq string (concat string | |
48 (buffer-substring | |
49 (point) | |
50 (min (save-excursion (end-of-line) (point)) | |
51 (+ n (point))))))) | |
52 (insert string))) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
53 |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
54 ;;; misc.el ends here |