Re: [O] function for inserting a block

2017-11-14 Thread Eric Abrahamsen
"Thomas S. Dye"  writes:

> Eric Abrahamsen writes:
>
>> Rasmus  writes:
>>
>>> Hi Eric,
>>>
>>> Eric Abrahamsen  writes:
>>>
> Also, Eric, it seems that org-structure-template-alist only supports a
> single letter for short-hands (the car of an entry in
> org-structure-template-alist is a char).  I used to have blocks like " expanding to an "abstract" special-block, which I guess isn’t possible
> anymore?

 I hadn't thought of that. Really, all I ever wanted was to wrap things
 in blocks...

 I don't see any reason why org-structure-template-alist couldn't go back
 to using string keys. Then we could use read-string, and wouldn't have
 to have special  behavior -- a string that didn't exist in the
 alist could just be used literally to make a block.
>>>
>>> I’d prefer that.  For some special blocks, a few characters might makes it
>>> more intuitive, e.g. "def" → "definition", "hyp" → "hypothesis" etc.
>>
>> Here's the simplest solution.
>>
>> There still remains the fact that `org-structure-template-alist' has
>> changed format, and `org-try-structure-completion' no longer exists.
>> That may still annoy some people who were using the internals of the
>> process, but...
>
> Would something like this work?
>
> (defun org-try-structure-completion ()
>   (tempo-complete-tag))

Here's the newest version!

It incorporates Rasmus' org-tempo.el file, with modifications, and
Thomas' suggestion to re-instate `org-try-structure-completion', and,
erm, stardiviner's request to honor
`org-babel-uppercase-example-markers'.

Remaining issues:

1. The "org-include" tempo template doesn't work, for reasons I don't
   understand (I've never used tempo before). Nothing happens when I hit
   .
2. Now it seems like there should be completion when prompting for a
   string key. Feature creep! But likely worthwhile feature creep.
3. I've rather rashly renamed the relevant customization options
   `org-structure-block-alist' (for blocks added via
   `org-insert-structure-template') and `org-structure-keyword-alist'
   (for keywords insertable via the tempo system). Perhaps this was a
   bad idea. If it's not a bad idea, maybe
   `org-insert-structure-template' should be renamed `org-insert-block'
   or something like that.
3. Docs need to be updated.

Comments welcome!

Eric

diff --git a/lisp/org-tempo.el b/lisp/org-tempo.el
new file mode 100644
index 0..ebe5a26c2
--- /dev/null
+++ b/lisp/org-tempo.el
@@ -0,0 +1,118 @@
+;;; org-tempo.el --- Tempo-style templates for Org -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+;;
+;; Author: Rasmus Pank Roulund 
+;; Keywords: outlines, hypermedia, calendar, wp
+;; Homepage: http://orgmode.org
+;;
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see .
+;;
+;;; Commentary:
+
+;; Block and structure templates, to replace the previous Org-specific
+;; system.  The old function `org-try-structure-completion' is
+;; provided as a thin wrapper around `tempo-complete-tag', for
+;; backwards compatibility.
+
+;;; Code:
+
+(require 'tempo)
+(require 'cl-lib)
+
+(defvar org-tempo-tags nil
+  "Tempo tags for org-mode")
+
+(defcustom org-structure-keyword-alist
+  '(("L" . "latex")
+("H" . "html")
+("A" . "ascii")
+("i" . "index"))
+  "Keyword templates expanded using the tempo package."
+  :group 'org-tempo
+  :type '(repeat
+	  (cons (string :tag "Key")
+		(string :tag "Template")))
+  :package-version '(Org . "9.2"))
+
+(defun org-tempo-setup ()
+  (tempo-use-tag-list 'org-tempo-tags)
+  (setq tempo-match-finder "^ *\\(<[[:word:]]\\)\\="))
+
+(add-hook 'org-mode-hook 'org-tempo-setup)
+
+(defun org-tempo-add-templates ()
+  "Update all org-tempo templates.
+Goes through `org-structure-block-alist' and
+`org-structure-keyword-alist'."
+  (let ((keys (mapcar (apply-partially #'format "<%s")
+		  (mapcar #'car (append org-structure-block-alist
+	org-structure-keyword-alist)
+(if (> (length keys)
+   (length (delete-dups keys)))
+	(user-error "Duplicate keys in `org-structure-template-alist' and `org-structure-template-alist-keywords'"))
+(dolist (key keys)
+  (if (assoc-string key org-tempo-tags)
+	  (setq org-tempo-tags
+		(delete (assoc-string key org-tempo-tags)
+			org-tempo-tags
+(mapc #'org-tempo-add-block org-structure-bloc

Re: [O] How to use case sensitive org-search-view?

2017-11-14 Thread Tim Cross

my 2 cents would vote for a variable which manages case folding. This
would be in-line with how isearch works and something familiar to most
Emacs users. I also prefer a single function which behaves differently
depending on a config variable setting over separate functions as I
think it makes key binding easier (though admittedly, it is trivial to
define a lambda which selects between different functions depending on
the setting of a config variable or prefix arg etc ).

Tim

Nicolas Goaziou  writes:

> Hello,
>
> Matt Lundin  writes:
>
>> alain.coch...@unistra.fr writes:
>>
>>> Hello. Sorry about this seemingly basic question, but I spent several
>>> hours (literally) googling and experimenting without any progress...
>>>
>>> Suppose I have an org file with
>>>
>>> * FOO * foo
>>>
>>> I would like to use org-search-view (C-c a s) so as to (say) list
>>> only the first entry.
>>>
>>> Among other things I tried using +FOO, +"FOO", +{FOO}, +{\bFOO\b},
>>> with case-fold-search being t or nil, with several emacs+org
>>> versions, but each time it lists both headlines.
>>>
>>> Is there a way to perform what I want?
>>
>> Unfortunately, it looks like org-search-view is hard-coded to be
>> case-insensitive. I think a very hackish workaround would be to advise
>> org-search-view to create and then remove an "around" advice that
>> wraps re-search-forward in a "let" declaration setting
>> case-fold-search to nil. But this would be a fairly horrific hack.
>>
>> In the long run, I believe the Org Mode code would need to be changed
>> to make this customizable.
>
> Note that there is `org-occur-case-fold-search'.
>
> We could implement something similar with, e.g.,
> `org-agenda-search-view-case-fold-search'. Or maybe use a variable for
> every search related function in Org: `org-case-fold-search'.
>
> WDYT?
>
>  Regards,


-- 
Tim Cross



Re: [O] How to use case sensitive org-search-view?

2017-11-14 Thread Nicolas Goaziou
Hello,

Matt Lundin  writes:

> alain.coch...@unistra.fr writes:
>
>> Hello. Sorry about this seemingly basic question, but I spent several
>> hours (literally) googling and experimenting without any progress...
>>
>> Suppose I have an org file with
>>
>> * FOO * foo
>>
>> I would like to use org-search-view (C-c a s) so as to (say) list
>> only the first entry.
>>
>> Among other things I tried using +FOO, +"FOO", +{FOO}, +{\bFOO\b},
>> with case-fold-search being t or nil, with several emacs+org
>> versions, but each time it lists both headlines.
>>
>> Is there a way to perform what I want?
>
> Unfortunately, it looks like org-search-view is hard-coded to be
> case-insensitive. I think a very hackish workaround would be to advise
> org-search-view to create and then remove an "around" advice that
> wraps re-search-forward in a "let" declaration setting
> case-fold-search to nil. But this would be a fairly horrific hack.
>
> In the long run, I believe the Org Mode code would need to be changed
> to make this customizable.

Note that there is `org-occur-case-fold-search'.

We could implement something similar with, e.g.,
`org-agenda-search-view-case-fold-search'. Or maybe use a variable for
every search related function in Org: `org-case-fold-search'.

WDYT?

 Regards,

-- 
Nicolas Goaziou



Re: [O] org-hide-emphasis-markers not mentioned in the org manual

2017-11-14 Thread Alain . Cochard
Thomas Rikl writes on Tue 14 Nov 2017 14:10:

 > (and perhaps other customization variables)
 > 
 > Version: Release 9.1.2 (release 9.1.2-192-gc029c4)
 > of the org manual
 > 
 > regards Thomas R.

In a recent (late sept.)  discussion on this list ("Confused about the
explanation for 'org-cycle"), it was argued by Org experts that
documenting every customization variable was not the best way to go.
So maybe this also applies for the particular case of
org-hide-emphasis-markers...

Regards


-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.coch...@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France| Fax:   +33 (0)3 68 85 01 25 



Re: [O] Bug: Org-mode easy templates stopped working after org-mode update [9.1.2 (release_9.1.2-190-g9cac9d @ /home/renato/.emacs.d/el-get/org-mode/lisp/)]

2017-11-14 Thread Eric Abrahamsen
Renato Candido  writes:

> Remember to cover the basics, that is, what you expected to happen and
> what in fact did happen.  You don't know how to make a good report?  See
>
>  http://orgmode.org/manual/Feedback.html#Feedback
>
> Your bug report will be posted to the Org mailing list.
> 
>
> Org-mode easy templates stopped working after org-mode update (e.g  expand). The current installed version is 9.1.2-190-g9cac9d.

We're in the midst of reworking that. The "

Re: [O] How to use case sensitive org-search-view?

2017-11-14 Thread Alain . Cochard
Matt Lundin writes on Tue 14 Nov 2017 08:26:

 > > Suppose I have an org file with
 > >
 > > * FOO
 > > * foo
 > >
 > > I would like to use org-search-view (C-c a s) so as to (say) list
 > > only the first entry.

 > Unfortunately, it looks like org-search-view is hard-coded to be
 > case-insensitive. I think a very hackish workaround would be to
 > advise org-search-view to create and then remove an "around" advice
 > that wraps re-search-forward in a "let" declaration setting
 > case-fold-search to nil. But this would be a fairly horrific hack.
 > 
 > In the long run, I believe the Org Mode code would need to be
 > changed to make this customizable.

In the meantime, shouldn't this "glitch" be mentioned in the manual?

The manual does say that 'C-c a s'

Create a list of entries selected by a boolean expression of
keywords and/or regular expressions [...]

Same problem for the 'C-c a s' minibuffer prompt:

Phrase or [+-]Word/{Regexp}

and the subsequent

Press `[', `]' to add/sub word, `{', `}' to add/sub regexp


I also realized that, consistently, using +{[[:upper:]]+o}, also lists
both entries.


Finally, trying to narrow the FOO + foo search results using '=':

`= (`org-agenda-filter-by-regexp')'
Filter the agenda view by a regular expression: only show
agenda entries matching the regular expression the user
entered.

and typing explicitly 'FOO' fails accordingly.


The tutorial
http://orgmode.org/worg/org-tutorials/advanced-searching.html does not
seem to mention this point either.


Anyway, thanks you very much for your time and feed back.

Regards
a.

PS: considering "horrific hack", I think you meant "In the /short/
run...", but I'm sure the Org developpers have understood it correctly
:-)


-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.coch...@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France| Fax:   +33 (0)3 68 85 01 25 



[O] Bug: Org-mode easy templates stopped working after org-mode update [9.1.2 (release_9.1.2-190-g9cac9d @ /home/renato/.emacs.d/el-get/org-mode/lisp/)]

2017-11-14 Thread Renato Candido
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


Org-mode easy templates stopped working after org-mode update (e.g mailto:"; path
   ("news" :follow
(lambda (path) (browse-url (concat "news:"; path
   ("shell" :follow org--open-shell-link))
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 )


Re: [O] How to use case sensitive org-search-view?

2017-11-14 Thread Matt Lundin
alain.coch...@unistra.fr writes:

> Hello.  Sorry about this seemingly basic question, but I spent several
> hours (literally) googling and experimenting without any progress...
>
> Suppose I have an org file with
>
> * FOO
> * foo
>
> I would like to use org-search-view (C-c a s) so as to (say) list only
> the first entry.
>
> Among other things I tried using +FOO, +"FOO", +{FOO}, +{\bFOO\b},
> with case-fold-search being t or nil, with several emacs+org versions,
> but each time it lists both headlines.
>
> Is there a way to perform what I want?

Unfortunately, it looks like org-search-view is hard-coded to be
case-insensitive. I think a very hackish workaround would be to advise
org-search-view to create and then remove an "around" advice that wraps
re-search-forward in a "let" declaration setting case-fold-search to
nil. But this would be a fairly horrific hack.

In the long run, I believe the Org Mode code would need to be changed to
make this customizable.

Best,
Matt



[O] org-hide-emphasis-markers not mentioned in the org manual

2017-11-14 Thread Thomas Rikl

(and perhaps other customization variables)

Version: Release 9.1.2 (release 9.1.2-192-gc029c4)
of the org manual

regards Thomas R.




[O] org-mode gets confused with column widths when 'time-stamp-custom-formats' are applied.

2017-11-14 Thread Ruy Exel
Consider the table below:

| Name  | Date of Birth|
|---+--|
| John  | <1978-11-14 Tue> |
| Peter | <1970-11-14 Sat> |
|---+--|

Suppose we want to format time stamps differently, such as with the
following elisp commands:

(setq org-time-stamp-custom-formats (quote ("<%d %b %y>" . "<%m/%d/%y %a
%H:%M>")))
(org-toggle-time-stamp-overlays)

After realigning the table you get

| Name  | Date of Birth|
|---+--|
| John  | <14 Nov 1978> |
| Peter | <14 Nov 1970> |
|---+--|

which is wrong because column widths are not uniform.  The reason, I
suppose, is that when computing column widths, org-mode ignores the fact
that the change of time stamps may have altered the length of the printed
string.

Best wishes,
Ruy Exel


[O] Table refuses to forget cell formula which once overrode a column formula

2017-11-14 Thread Ruy Exel
This bug report is motivated by a question I asked at


https://emacs.stackexchange.com/questions/36855/table-refuses-to-forget-cell-formula-which-once-overrode-a-column-formula

and all of the necessary information can probably be obtained from there.
Nevertheless let me repeat it here:

-

The following is very simple org-mode spreadsheet in which the cells in the
second column show the triple of the corresponding cell in the first column
due to the "column formula" in its TBLFM row $2=3*$1;N. However the third
row (actually row @4) is an exception because of the "cell formula"
@4$2=string("Exception") which expectedly overrides the above column
formula.

|+---|
| Number |Triple |
|+---|
|  1 | 3 |
|  2 | 6 |
|  3 | Exception |
|  4 |12 |
|+---|
#+TBLFM: $2=3*$1::@4$2=string("Exception")

So all is well. Below you will find a copy of the above table, except that,
after copying, I have deleted the exceptional formula affecting cell @4$2.

|+---|
| Number |Triple |
|+---|
|  1 | 3 |
|  2 | 6 |
|  3 | Exception |
|  4 |12 |
|+---|
#+TBLFM: $2=3*$1

One would expect that, after updating this table with C-u C-c *, or C-c C-c
in the TBLFM line, the exceptional value in cell @4$2 would revert to the
triple of '3', but instead the string "Exception" stays put. Is this a bug
or am I doing something wrong?

I noticed that if I save the file, close it (kill-buffer) and then reopen
it, the strange behaviour disapears, namely, updating the table with C-u
C-c * causes cell @4$2 to turn to '9', as expected.

I am using GNU Emacs 24.3.1 and the latest version of org-mode.

-

The answer I got from emacs.stackexchange.com says:

-

The persistence of the string exception has nothing to do with copying. If
you recalculate the original table and afterwards remove the field formula
from it you also have the problem that exception is not replaced by 9 at
the next recalculation.

The reason for that behavior is that the text property :org-untouchable is
put on the output of field formulas. The normal function of
:org-untouchable is to prevent the modification of cells with field
formulas during the evaluation of a column formulas.

In my opinion the :org-untouchable property should be removed at the
beginning of calls to org-table-iterate and at the beginning of interactive
calls of org-table-recalculate.

You can obtain this behavior with the advices below. These advices are
tested with org-version 9.0.5 in emacs 25.1.50.2.

I would agree that the original behavior is faulty. Therefore, I suggest to
file a bug-report at https://lists.gnu.org/mailman/listinfo/emacs-orgmode.
A proper bug-fix should probably be implemented differently.

(defun org-table-remove-untouchable (&rest _args)
  "Remove `:org-untouchable' property from org-table."
  (save-excursion
(cl-assert (org-at-table-p) nil "Not in org-table.")
(remove-text-properties (org-table-begin) (org-table-end)
'(:org-untouchable nil

(defun org-table-recalculate-remove-untouchable (&optional all _noalign)
  "Remove `:org-untouchable' property at the beginning of
`org-table-iterate'.
Use this function as :before advice of `org-table-iterate'."
  (when (and (called-interactively-p 'any)
 all)
(org-table-remove-untouchable)))

(advice-add 'org-table-iterate :before #'org-table-remove-untouchable)
(advice-add 'org-table-recalculate :before
#'org-table-recalculate-remove-untouchable)

-

Sincerely,
Ruy Exel