home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!gumby!wupost!uwm.edu!linac!att!rutgers!ub!dsinc!bagate!cbmvax!snark!esr
- From: esr@snark.thyrsus.com (Eric S. Raymond)
- Newsgroups: comp.emacs
- Subject: Can anyone identify this code?
- Message-ID: <1hBdv1#4TF1G93cw80Y2lKydp0qPJ0Z=esr@snark.thyrsus.com>
- Date: 21 Jul 92 14:47:32 GMT
- Followup-To: poster
- Lines: 40
-
- This was found in a dusty corner of the Emacs 19 distribution. Both its
- authorship and its intended use are obscure. Can anyone shed any light?
-
- ------------------------------- CUT HERE --------------------------------------
-
- (defun copy-from-above-command (&optional arg)
- "Copy characters from previous nonblank line, starting just above point.
- Copy ARG characters, but not past the end of that line.
- If no argument given, copy the entire rest of the line.
- The characters copied are inserted in the buffer before point."
- (interactive "P")
- (let ((cc (current-column))
- n
- (string ""))
- (save-excursion
- (beginning-of-line)
- (backward-char 1)
- (skip-chars-backward "\ \t\n")
- (move-to-column cc)
- ;; Default is enough to copy the whole rest of the line.
- (setq n (if arg (prefix-numeric-value arg) (point-max)))
- ;; If current column winds up in middle of a tab,
- ;; copy appropriate number of "virtual" space chars.
- (if (< cc (current-column))
- (if (= (preceding-char) ?\t)
- (progn
- (setq string (make-string (min n (- (current-column) cc)) ?\ ))
- (setq n (- n (min n (- (current-column) cc)))))
- ;; In middle of ctl char => copy that whole char.
- (backward-char 1)))
- (setq string (concat string
- (buffer-substring
- (point)
- (min (save-excursion (end-of-line) (point))
- (+ n (point)))))))
- (insert string)))
-
- ------------------------------- CUT HERE --------------------------------------
- --
- Eric S. Raymond = esr@snark.thyrsus.com
-