[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Yank "normal" text as item in list
From: |
Teika Kazura |
Subject: |
Re: [O] Yank "normal" text as item in list |
Date: |
Sat, 25 Oct 2014 10:05:34 +0900 (JST) |
Hi, Igor. Below is mine. It's rudimentary, but it may help you.
------------------------------------------------------------------------
(defun teika-org-yank (&optional arg)
"Wrapper of `org-yank', taking care of indenting."
(interactive)
(let (p0 p1)
(when
(and kill-ring
(bolp)
(not (equal (substring-no-properties (car kill-ring) 0 1) "*"))
(not (equal (buffer-substring-no-properties (point) (1+ (point)))
"*" )))
(setq p0 (point))
(org-cycle))
(call-interactively 'org-yank)
(when p0
(indent-region p0 (point))
(unless (eolp)
(org-cycle)))))
(define-key org-mode-map "\C-y" 'teika-org-yank)
;; Obviously `p1' inside of `let' is not used. Sorry for bad lisp. =P
;; By the way, I have this:
(global-set-key [(shift ?\s )] 'just-one-space)
(global-set-key [(meta ?\s )] 'delete-horizontal-space)
;; You can easily press S-space and M-space with thumbs with my hack in Linux:
;; https://forums.gentoo.org/viewtopic-t-865313.html
;; (if you have a Japanese keyboard.)
;; I also bind to a key the following, a code fragment of a bigger function.
(progn
(exchange-point-and-mark)
(when (or (eq last-command 'yank)
(eq last-command 'yank-pop))
(just-one-space)
))
;; I.e., right after yanking, it calls `just-one-space'. Adjust to your use.
------------------------------------------------------------------------
In fact, it was a surprise for me that none has answered with a nice
implementation. Indent problem irritated me a lot.
Cheers,
Teika (Teika kazura)