Re: [patch] When inserting entry template, don't include last newline in narrowed zone

2020-06-28 Thread E.L.K.
Just found an issue with this patch: if I try to schedule the item,
SCHEDULED and timestamp get inserted into invisible area.

Thanks,
Alexey

On Sun, Jun 28, 2020 at 1:14 PM E.L.K.  wrote:

> Hello.
>
> Org 9.3.6: when inserting the entry by capture mechanics, it narrows
> buffer in a way that cursor can be moved to the last line, which is the
> beginning of next (non-capture template) line in the original unnarowed
> buffer.
>
> So this allows to: start capture, move point to the very last char of the
> narrowed buffer, insert something. If this line in unnarowed buffer was
> start of heading, it breaks structure of document.
>
> This is patch in attempt to fix it. I followed same approach as in
> org-capture-place-item function.
>
> Thanks,
> Alexey
>


[patch] When inserting entry template, don't include last newline in narrowed zone

2020-06-28 Thread E.L.K.
Hello.

Org 9.3.6: when inserting the entry by capture mechanics, it narrows buffer
in a way that cursor can be moved to the last line, which is the beginning
of next (non-capture template) line in the original unnarowed buffer.

So this allows to: start capture, move point to the very last char of the
narrowed buffer, insert something. If this line in unnarowed buffer was
start of heading, it breaks structure of document.

This is patch in attempt to fix it. I followed same approach as in
org-capture-place-item function.

Thanks,
Alexey
Common subdirectories: org-9.3.6/etc and /home/elk/.emacs.d/elpa/org-9.3.6/etc
diff -U5 org-9.3.6/org-capture.el /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el
--- org-9.3.6/org-capture.el	2020-06-15 19:04:19.061012833 +0300
+++ /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el	2020-06-28 13:08:04.446045559 +0300
@@ -1149,11 +1149,11 @@
 	  (org-paste-subtree level template 'for-yank))
 	(org-capture-position-for-last-stored beg)
 	(org-capture-empty-lines-after)
 	(unless (org-at-heading-p) (outline-next-heading))
 	(org-capture-mark-kill-region origin (point))
-	(org-capture-narrow beg (point))
+	(org-capture-narrow beg (1- (point)))
 	(when (or (search-backward "%?" beg t)
 		  (search-forward "%?" nil t))
 	  (replace-match ""))
 
 (defun org-capture-place-item ()



Org mode patch: when building sparse tree, suggest only local tags in minibuffer

2020-06-19 Thread E.L.K.
Hello.

I found that if I do "C-c C-c" on heading, it suggests only local tags in
the minibuffer, but when I do "C-m / m" (build sparse tree) it suggests
agenda tags together with local tags.

It does not make sense to build sparse tree in buffer using tags that are
not in this buffer, I think. So there is small patch in attempt to fix it.

Thanks!

I'm not subscribed, so please CC me.
Common subdirectories: /home/elk/.emacs.d/elpa/org-9.3.6/etc and /home/elk/temp/org-9.3.6/etc
diff -U 10 --color /home/elk/.emacs.d/elpa/org-9.3.6/org.el /home/elk/temp/org-9.3.6/org.el
--- /home/elk/.emacs.d/elpa/org-9.3.6/org.el	2020-06-15 19:07:22.148502633 +0300
+++ /home/elk/temp/org-9.3.6/org.el	2020-06-15 19:04:18.927678900 +0300
@@ -11924,21 +11924,21 @@
 MATCH is a string with match syntax.  It can contain a selection
 of tags (\"+work+urgent-boss\"), properties (\"LEVEL>3\"), and
 TODO keywords (\"TODO=\\\"WAITING\\\"\") or a combination of
 those.  See the manual for details.
 
 If optional argument TODO-ONLY is non-nil, only select lines that
 are also TODO tasks."
   (interactive "P")
   (org-agenda-prepare-buffers (list (current-buffer)))
   (let ((org--matcher-tags-todo-only todo-only))
-(org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match t))
+(org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match))
 		   org--matcher-tags-todo-only)))
 
 (defalias 'org-tags-sparse-tree 'org-match-sparse-tree)
 
 (defvar org-cached-props nil)
 (defun org-cached-entry-get (pom property)
   (if (or (eq t org-use-property-inheritance)
 	  (and (stringp org-use-property-inheritance)
 	   (let ((case-fold-search t))
 		 (string-match-p org-use-property-inheritance property)))
@@ -11965,21 +11965,21 @@
 		 (set-buffer (find-file-noselect file))
 		 (org--tag-add-to-alist
 		  (org-get-buffer-tags)
 		  (mapcar (lambda (x)
 (and (stringp (car-safe x))
  (list (car-safe x
 			  org-current-tag-alist)))
 		   (if (car-safe files) files
 		 (org-agenda-files
 
-(defun org-make-tags-matcher (match  only-local-tags)
+(defun org-make-tags-matcher (match)
   "Create the TAGS/TODO matcher form for the selection string MATCH.
 
 Returns a cons of the selection string MATCH and a function
 implementing the matcher.
 
 The matcher is to be called at an Org entry, with point on the
 headline, and returns non-nil if the entry matches the selection
 string MATCH.  It must be called with three arguments: the TODO
 keyword at the entry (or nil if none), the list of all tags at
 the entry including inherited ones and the reduced level of the
@@ -11990,22 +11990,21 @@
 a non-nil value if the matcher restricts matching to TODO
 entries, otherwise it is not touched.
 
 See also `org-scan-tags'."
   (unless match
 ;; Get a new match request, with completion against the global
 ;; tags table and the local tags in current buffer.
 (let ((org-last-tags-completion-table
 	   (org--tag-add-to-alist
 	(org-get-buffer-tags)
-	(unless only-local-tags
-  (org-global-tags-completion-table)
+	(org-global-tags-completion-table
   (setq match
 	(completing-read
 	 "Match: "
 	 'org-tags-completion-function nil nil nil 'org-tags-history
 
   (let ((match0 match)
 	(re (concat
 	 "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)"
 	 "\\([0-9]+\\)\\|\\(\\(?:[[:alnum:]_]+\\(?:-\\)*\\)+\\)"
 	 "\\([<>=]\\{1,2\\}\\)"
Binary files /home/elk/.emacs.d/elpa/org-9.3.6/org.elc and /home/elk/temp/org-9.3.6/org.elc differ


Org mode patch: when building sparse tree, suggest only local tags in minibuffer

2020-06-16 Thread E.L.K.
Hello.

I found that if I do "C-c C-c" on heading, it suggests only local tags in
the minibuffer, but when I do "C-m / m" (build sparse tree) it suggests
agenda tags together with local tags.

It does not make sense to build sparse tree in buffer using tags that are
not in this buffer, I think. So there is small patch in attempt to fix it.

Thanks!
Common subdirectories: /home/elk/.emacs.d/elpa/org-9.3.6/etc and /home/elk/temp/org-9.3.6/etc
diff -U 10 --color /home/elk/.emacs.d/elpa/org-9.3.6/org.el /home/elk/temp/org-9.3.6/org.el
--- /home/elk/.emacs.d/elpa/org-9.3.6/org.el	2020-06-15 19:07:22.148502633 +0300
+++ /home/elk/temp/org-9.3.6/org.el	2020-06-15 19:04:18.927678900 +0300
@@ -11924,21 +11924,21 @@
 MATCH is a string with match syntax.  It can contain a selection
 of tags (\"+work+urgent-boss\"), properties (\"LEVEL>3\"), and
 TODO keywords (\"TODO=\\\"WAITING\\\"\") or a combination of
 those.  See the manual for details.
 
 If optional argument TODO-ONLY is non-nil, only select lines that
 are also TODO tasks."
   (interactive "P")
   (org-agenda-prepare-buffers (list (current-buffer)))
   (let ((org--matcher-tags-todo-only todo-only))
-(org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match t))
+(org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match))
 		   org--matcher-tags-todo-only)))
 
 (defalias 'org-tags-sparse-tree 'org-match-sparse-tree)
 
 (defvar org-cached-props nil)
 (defun org-cached-entry-get (pom property)
   (if (or (eq t org-use-property-inheritance)
 	  (and (stringp org-use-property-inheritance)
 	   (let ((case-fold-search t))
 		 (string-match-p org-use-property-inheritance property)))
@@ -11965,21 +11965,21 @@
 		 (set-buffer (find-file-noselect file))
 		 (org--tag-add-to-alist
 		  (org-get-buffer-tags)
 		  (mapcar (lambda (x)
 (and (stringp (car-safe x))
  (list (car-safe x
 			  org-current-tag-alist)))
 		   (if (car-safe files) files
 		 (org-agenda-files
 
-(defun org-make-tags-matcher (match  only-local-tags)
+(defun org-make-tags-matcher (match)
   "Create the TAGS/TODO matcher form for the selection string MATCH.
 
 Returns a cons of the selection string MATCH and a function
 implementing the matcher.
 
 The matcher is to be called at an Org entry, with point on the
 headline, and returns non-nil if the entry matches the selection
 string MATCH.  It must be called with three arguments: the TODO
 keyword at the entry (or nil if none), the list of all tags at
 the entry including inherited ones and the reduced level of the
@@ -11990,22 +11990,21 @@
 a non-nil value if the matcher restricts matching to TODO
 entries, otherwise it is not touched.
 
 See also `org-scan-tags'."
   (unless match
 ;; Get a new match request, with completion against the global
 ;; tags table and the local tags in current buffer.
 (let ((org-last-tags-completion-table
 	   (org--tag-add-to-alist
 	(org-get-buffer-tags)
-	(unless only-local-tags
-  (org-global-tags-completion-table)
+	(org-global-tags-completion-table
   (setq match
 	(completing-read
 	 "Match: "
 	 'org-tags-completion-function nil nil nil 'org-tags-history
 
   (let ((match0 match)
 	(re (concat
 	 "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)"
 	 "\\([0-9]+\\)\\|\\(\\(?:[[:alnum:]_]+\\(?:-\\)*\\)+\\)"
 	 "\\([<>=]\\{1,2\\}\\)"
Binary files /home/elk/.emacs.d/elpa/org-9.3.6/org.elc and /home/elk/temp/org-9.3.6/org.elc differ