emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Teika Kazura <teika@gmx.com>
To: emacs-orgmode@gnu.org
Cc: joseleopoldo1792@gmail.com
Subject: Re: Yank "normal" text as item in list
Date: Sat, 25 Oct 2014 10:05:34 +0900 (JST)	[thread overview]
Message-ID: <20141025.100534.1353119178504294949.teika@gmx.com> (raw)
In-Reply-To: <87h9yv85oq.fsf@pedroche.home>

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)

  parent reply	other threads:[~2014-10-25  1:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 10:02 Yank "normal" text as item in list Igor Sosa Mayor
2014-10-23 15:18 ` Rasmus
2014-10-23 15:26   ` Igor Sosa Mayor
2014-10-23 15:29 ` Alexander Baier
2014-10-23 16:01   ` Igor Sosa Mayor
2014-10-24  3:53 ` Eric Abrahamsen
2014-10-24 20:08   ` Igor Sosa Mayor
2014-10-25  1:05 ` Teika Kazura [this message]
2014-10-29 14:53   ` Igor Sosa Mayor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141025.100534.1353119178504294949.teika@gmx.com \
    --to=teika@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=joseleopoldo1792@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).