Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Moving point location
- ;; don't add newlines to end of buffer when scrolling
- (setq next-line-add-newlines nil)
- ;; XEmacs default for moving point to a given line number
- (GNUEmacs
- (global-set-key (kbd "M-g") 'goto-line))
- (global-set-key (kbd "M-G") 'what-line)
- ;; move (shift) a line of text up or down like you would in Eclipse
- ;; press `M-up' (or `M-down')
- (defun move-line (n)
- "Move the current line up or down by N lines."
- (interactive "p")
- (let ((col (current-column))
- start
- end)
- (beginning-of-line)
- (setq start (point))
- (end-of-line)
- (forward-char)
- (setq end (point))
- (let ((line-text (delete-and-extract-region start end)))
- (forward-line n)
- (insert line-text)
- ;; restore point to original column in moved line
- (forward-line -1)
- (forward-char col))))
- (defun move-line-up (n)
- "Move the current line up by N lines."
- (interactive "p")
- (move-line (if (null n) -1 (- n))))
- (defun move-line-down (n)
- "Move the current line down by N lines."
- (interactive "p")
- (move-line (if (null n) 1 n)))
Advertisement
Add Comment
Please, Sign In to add comment