Nicolas Goaziou <[email protected]> writes:
[...]
> Then it's `forward-line', not `forward-char', because there could be
> trailing spaces at the end of the paragraph, e.g.
>
> This is a paragraph.<SPC><SPC>
Okay, changed to `forward-line'.
> Also, my question still holds, what about the last paragraph in a buffer
> not ending with a newline character, e.g.
>
> This is the last paragraph.<EOB>
>
> You need to insert a newline character in this case.
I'm still not quite seeing this. This chunk should take care of it:
(goto-char e)
(if (bolp)
(progn
(skip-chars-backward " \n\t")
(forward-line))
(end-of-line)
(insert "\n"))
If "e" is EOB, we do `end-of-line' and insert a newline, it should be
taken care of. I added a new clause in the test for this case, and it
seems to work fine... Am I missing anything?
Eric
>From 7ac8883394bc2979dee731c54ef65c0a9c135d0b Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <[email protected]>
Date: Tue, 17 Oct 2017 10:11:21 +0200
Subject: [PATCH] Move `org-completing-read' into "org-macs.el"
* lisp/org-macs.el (org-completing-read): Moved here...
* lisp/org.el: ... from there.
---
lisp/org-macs.el | 35 +++++++++++++++++++++++++----------
lisp/org.el | 10 ----------
2 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 1a2d8a49d..196a2ce22 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -168,6 +168,31 @@ point nowhere."
+;;; Input
+
+(defun org-read-function (prompt &optional allow-empty?)
+ "Prompt for a function.
+If ALLOW-EMPTY? is non-nil, return nil rather than raising an
+error when the user input is empty."
+ (let ((func (completing-read prompt obarray #'fboundp t)))
+ (cond ((not (string= func ""))
+ (intern func))
+ (allow-empty? nil)
+ (t (user-error "Empty input is not valid")))))
+
+(defun org-completing-read (&rest args)
+ "Completing-read with SPACE being a normal character."
+ (let ((enable-recursive-minibuffers t)
+ (minibuffer-local-completion-map
+ (copy-keymap minibuffer-local-completion-map)))
+ (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
+ (org-defkey minibuffer-local-completion-map "?" 'self-insert-command)
+ (org-defkey minibuffer-local-completion-map (kbd "C-c !")
+ 'org-time-stamp-inactive)
+ (apply #'completing-read args)))
+
+
+
;;; Logic
(defsubst org-xor (a b)
@@ -469,16 +494,6 @@ The number of levels is controlled by `org-inlinetask-min-level'"
limit-level)))
(format "\\*\\{1,%d\\} " nstars)))))
-(defun org-read-function (prompt &optional allow-empty?)
- "Prompt for a function.
-If ALLOW-EMPTY? is non-nil, return nil rather than raising an
-error when the user input is empty."
- (let ((func (completing-read prompt obarray #'fboundp t)))
- (cond ((not (string= func ""))
- (intern func))
- (allow-empty? nil)
- (t (user-error "Empty input is not valid")))))
-
(provide 'org-macs)
diff --git a/lisp/org.el b/lisp/org.el
index e3b4ccef1..99eba2da3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10322,16 +10322,6 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
(match-string 1 (expand-file-name file))))
(t (concat "file:" file)))))
-(defun org-completing-read (&rest args)
- "Completing-read with SPACE being a normal character."
- (let ((enable-recursive-minibuffers t)
- (minibuffer-local-completion-map
- (copy-keymap minibuffer-local-completion-map)))
- (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
- (org-defkey minibuffer-local-completion-map "?" 'self-insert-command)
- (org-defkey minibuffer-local-completion-map (kbd "C-c !")
- 'org-time-stamp-inactive)
- (apply #'completing-read args)))
;;; Opening/following a link
--
2.14.2