From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: function for inserting a block Date: Tue, 17 Oct 2017 09:27:14 -0700 Message-ID: <87lgk9eo4d.fsf@ericabrahamsen.net> References: <877exghblx.fsf@ericabrahamsen.net> <87efromccg.fsf@nicolasgoaziou.fr> <87ziabepxt.fsf@ericabrahamsen.net> <87bmml2fb0.fsf@ericabrahamsen.net> <87fubuzpsa.fsf@nicolasgoaziou.fr> <874lsabdop.fsf@ericabrahamsen.net> <87vak1l11m.fsf@nicolasgoaziou.fr> <87r2uoc4q7.fsf@ericabrahamsen.net> <87bmllk5xy.fsf@nicolasgoaziou.fr> <878tgmwwsa.fsf@ericabrahamsen.net> <87po9q2e8k.fsf@nicolasgoaziou.fr> <87tvyyvpst.fsf@ericabrahamsen.net> <87fuaiz069.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Uk6-0005Bv-CS for emacs-orgmode@gnu.org; Tue, 17 Oct 2017 12:29:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Uk3-0003EJ-N5 for emacs-orgmode@gnu.org; Tue, 17 Oct 2017 12:29:22 -0400 Received: from [195.159.176.226] (port=36211 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4Uk3-0003DG-Dt for emacs-orgmode@gnu.org; Tue, 17 Oct 2017 12:29:19 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1e4Ujf-0006V9-W5 for emacs-orgmode@gnu.org; Tue, 17 Oct 2017 18:28:56 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Nicolas Goaziou 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. 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. > > 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Move-org-completing-read-into-org-macs.el.patch >From 7ac8883394bc2979dee731c54ef65c0a9c135d0b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou 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 --=-=-=--