First, here's a way to insert at current position the last message printed
into the minibuffer... well not exactly, in *Messages* buffer in fact. I was
tired of doing it myself after invoking, e.g., M-x emacs-version.
;; print last message ;; current-message is already lost by the time this gets called (defun dim:previous-message (&optional nth) "get last line of *Message* buffer" (with-current-buffer (get-buffer "*Messages*") (save-excursion (goto-char (point-max)) (setq nth (if nth nth 1)) (while (> nth 0) (previous-line) (setq nth (- nth 1))) (buffer-substring (line-beginning-position) (line-end-position))))) (defun dim:insert-previous-message (&optional nth) "insert last message of *Message* to current position" (interactive "p") (insert (format "%s" (dim:previous-message nth)))) (global-set-key (kbd "C-c m") 'dim:insert-previous-message)
Now I stumbled accross Planet Emacsen and saw this Emacs Utility Functions
post, containing a version of duplicate-current-line that I didn't
like... here's mine:
;; duplicate current line (defun duplicate-current-line (&optional n) "duplicate current line, make more than 1 copy given a numeric argument" (interactive "p") (save-excursion (let ((nb (or n 1)) (current-line (thing-at-point 'line))) ;; when on last line, insert a newline first (when (or (= 1 (forward-line 1)) (eq (point) (point-max))) (insert "\n")) ;; now insert as many time as requested (while (> n 0) (insert current-line) (decf n))))) (global-set-key (kbd "C-S-d") 'duplicate-current-line)
And a last one inspired by some strange vim behavior for which I fail to see
a need:
;; on request by cyrilb, who missed it from vim ;; no global-set-key yet, still have to think I'll use it someday... (defun copy-char-from-prev-line () "Copy char at same position on previous line, when such a line and position exists" (interactive) (let ((c) (p (- (point) (line-beginning-position)))) (save-excursion (when (eq 0 (forward-line -1)) (when (< (+ (point) p) (line-end-position)) (forward-char p) (setq c (thing-at-point 'char))))) (when c (insert c))))
Next time I'll try to talk about rcirc-groups or cssh which have managed to
take some of my free time recently.
Tags
Previous Articles
- PgCon 2009 Wednesday, May 27 2009, 14:30
- prefix extension reaches 1.0 (rc1) Tuesday, June 23 2009, 10:53
- prefix 1.0~rc2-1 Thursday, July 09 2009, 12:48
- prefix 1.0~rc2 in debian testing Monday, August 03 2009, 14:50
Next Articles
- hstore-new & preprepare reach debian too Tuesday, August 18 2009, 09:14
- Improving ~/.mailrc usage Monday, September 07 2009, 01:29
- Follow-up on dim:mailrc-add-entry Monday, September 07 2009, 12:50
- Escreen integration Tuesday, September 22 2009, 23:04

