From: Le Wang <l26wang@gmail.com>
To: Orgmode Mailing List <emacs-orgmode@gnu.org>
Subject: [PATCH] org-edit-special too much space if starting with empty block
Date: Mon, 5 Nov 2012 22:31:01 +0800 [thread overview]
Message-ID: <CAM=K+ipumynnMyvsg27xPB9YeeADQO-VZwd8+p3RvK_DHRGHvQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 362 bytes --]
Some tests:
Case 1:
Start with emacs -Q
I insert
"
#+begin_src javascript
#+end_src
"
with point before "#+end_src", I press " C-c ' " to start editing the source
I enter "foobar" into the source buffer and immediately exit with " C-c ' "
Case 2:
restart with
"
#+begin_src javascript
#+end_src
"
I've included a patch that fixes both issues.
--
Le
[-- Attachment #2: org-src.el.3.diff --]
[-- Type: application/octet-stream, Size: 1412 bytes --]
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 75db1d7..064bf19 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -215,11 +215,19 @@ buffer."
(setq org-edit-src-saved-temp-window-config (current-window-configuration)))
(let* ((mark (and (org-region-active-p) (mark)))
(case-fold-search t)
- (info (org-edit-src-find-region-and-lang))
+ (info (let* ((first-pass (org-edit-src-find-region-and-lang))
+ (first-pass-beg (nth 0 first-pass))
+ (first-pass-end (nth 1 first-pass)))
+ (if (< first-pass-end first-pass-beg)
+ (progn
+ (goto-char first-pass-beg)
+ (insert "\n")
+ (org-edit-src-find-region-and-lang))
+ first-pass)))
(full-info (org-babel-get-src-block-info 'light))
(org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
(beg (make-marker))
- (end (make-marker))
+ (end (copy-marker nil t))
(allow-write-back-p (null code))
block-nindent total-nindent ovl lang lang-f single lfmt buffer msg
begline markline markcol line col transmitted-variables)
@@ -692,7 +700,8 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
(delete-region beg (max beg (1- end)))
(unless (string-match "\\`[ \t]*\\'" code)
(insert code)
- (delete-char 1))
+ (unless (= (point) end)
+ (delete-char 1)))
(goto-char beg)
(if single (just-one-space)))
(if (memq t (mapcar (lambda (overlay)
next reply other threads:[~2012-11-05 14:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-05 14:31 Le Wang [this message]
2012-11-08 12:33 ` [PATCH] org-edit-special too much space if starting with empty block Le Wang
2012-11-09 0:23 ` Nicolas Goaziou
2012-11-18 5:49 ` Le Wang
2012-11-23 14:54 ` Le Wang
2012-11-30 13:23 ` Nicolas Goaziou
2012-12-13 14:05 ` Le Wang
2012-12-13 14:05 ` Nicolas Goaziou
2012-12-13 15:15 ` Bastien
2012-12-13 15:53 ` Le Wang
2012-12-13 16:00 ` Bastien
2012-12-13 18:09 ` Achim Gratz
2012-12-13 21:53 ` Le Wang
2012-12-13 22:20 ` Bastien
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='CAM=K+ipumynnMyvsg27xPB9YeeADQO-VZwd8+p3RvK_DHRGHvQ@mail.gmail.com' \
--to=l26wang@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).