Re: [O] bug: org-table-sort-lines does only case sensitive alphabetical sorting

2018-07-19 Thread Heikki Lehvaslaiho
My emacs is from homebrew without any manual settings on locale. I assume a
number of locale settings come with it. I have not had any problems before
this.

OS X does not have LANG envvar set. This computer came with Finnish
language set and I switched to English (Australian) for interface. This has
lead to somewhat weird locale setting at OS:

$ defaults read .GlobalPreferences AppleLanguages
(
"en-FI"
)

Apart from ssa, the output from string-collate-lessp seems to be what is to
be expected:

(string-collate-lessp "a" "x" "de_DE.utf-8" nil) ; t
(string-collate-lessp "a" "X" "de_DE.utf-8" nil) ; nil
(string-collate-lessp "ß" "ssa" "de_DE.utf-8") ; nil
(string-lessp "ß" "ssa")   ; nil
(string-collate-lessp "ä" "ö" "fi_FI.utf-8") ; t
(string-collate-lessp "Ä" "ö" "fi_FI.utf-8") ; t

I can not able to comment on C code, but it really seems that alphabetic
sorting is fixed to case-sensitive mode.




 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki

On 17 July 2018 at 09:59, Sebastian Reuße  wrote:

>
> Heikki Lehvaslaiho  writes:
>
> > x86_64-apple-darwin14.5.0
>
> Looking at the C source of ‘string-collate-lessp’ (src/fns.c), it looks
> like there exists a case where Emacs itself will fall back on
> ‘string-lessp’ even when ‘string-collate-lessp’ is invoked.
>
> #else  /* !__STDC_ISO_10646__, !WINDOWSNT */
>  return Fstring_lessp (s1, s2);
> #endif /* !__STDC_ISO_10646__, !WINDOWSNT */
>
> I can’t tell what the first macro evaluates to on your platform. Might
> this be the cause?
>
> An indication for whether your Emacs uses the locale at all may be
> testing the following (presuming you have the German locale data
> installed and compiled):
>
> (string-collate-lessp "ß" "ssa" "de_DE.utf-8") ; t
> (string-lessp "ß" "ssa")   ; nil
>
> This is based on the German ‘ß’ ligature being sorted as if it were
> equal to the string ‘ss’ (you can probably construct something analogous
> using fi_FI). If the first call returns nil, your Emacs isn’t using the
> locale data at all.
>
> Kind regards,
> SR
>
> --
> Insane cobra split the wood
> Trader of the lowland breed
> Call a jittney, drive away
> In the slipstream we will stay
>


Re: [O] bug: org-table-sort-lines does only case sensitive alphabetical sorting

2018-07-17 Thread Heikki Lehvaslaiho
Thanks for replies,

I am using:
GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17
Version 10.10.5 (Build 14F2511)) of 2018-05-31


This is what I get:

(string-collate-lessp "a" "x" "de_DE.utf-8" nil) ; t
(string-collate-lessp "a" "X" "de_DE.utf-8" t) ; nil
(string-collate-lessp "a" "x" "fi_FI.utf-8" nil) ; t
(string-collate-lessp "a" "X" "fi_FI.utf-8" t) ; nil


I think I have lost the sense how Emacs language environments work
after struggling for years with buffers getting automatically
converted to Latin-1. I started setting all possible variables to
'UTF-8 and finally something did it.

Now I tried again various values to see if they affect the org table
sorting:

(set-language-environment 'utf-8)
(set-language-environment 'English)
(set-language-environment 'Swedish)

(setq locale-coding-system 'utf-8)
(setq locale-coding-system 'fi_FI.utf-8)
(setq locale-coding-system 'de_DE.utf-8)
(setq locale-coding-system 'en_GB.utf-8)

Unfortunately none of these made any difference. Any suggestions?

I am testing sorting in a simple one column table:

| a |
| c |
| B |
| D |




 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki

On 14 July 2018 at 15:31, Sebastian Reuße  wrote:

> Hello Nicolas, hello Heikki,
>
> > Heikki Lehvaslaiho  writes:
>
> >> I can not see any change in function with the new code. Alphabetical
> >> sorting is fixedly case sensitive.
>
> Is your Emacs≤24? Emacs (surprisingly) only gained a facility for
> alphabetic (locale-sensitive) sorting with ver. 25. Before that, we will
> resort to using «string-lessp», which only sorts lexicographically (i.e,
> based on the binary character value, which means it is always
> case-sensitive on Unicode systems).
>
> If you are using GNU Emacs≥25, what locale are you using? FI_fi and most
> of the other western locales are based on ISO-14651, so you should
> always get case-*in*sensitive orderings, which is what I get with Emacs
> 26.1. So, evaluating the following should all yield «t»:
>
> (string-collate-lessp "a" "x" "de_DE.utf-8" nil)
> (string-collate-lessp "a" "X" "de_DE.utf-8" t)
> (string-collate-lessp "a" "x" "fi_FI.utf-8" nil)
> (string-collate-lessp "a" "X" "fi_FI.utf-8" t)
>
> Kind regards,
>
> Sebastian
>
> --
> Insane cobra split the wood
> Trader of the lowland breed
> Call a jittney, drive away
> In the slipstream we will stay
>


Re: [O] bug: org-table-sort-lines does only case sensitive alphabetical sorting

2018-07-12 Thread Heikki Lehvaslaiho
I can not see any change in function with the new code. Alphabetical
sorting is fixedly case sensitive.

I am definitely running the new code for org-table-sort-lines at the head
of the master branch. I can see there have been changes. Universal argument
does not change the behaviour, either.

I am running this OS X High Sierra with English as a default language, so
the problem should not be the locale.


 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki

On 4 July 2018 at 19:16, Nicolas Goaziou  wrote:

> Hello,
>
> Heikki Lehvaslaiho  writes:
>
> > org-sort has an optional argument with-case. By default its sorting
> ignores
> > the case. When org-sort is called within a table, it calls
> > org-table-sort-line with the argument. org-table-sort-line defines a let
> > variable sort-fold-case (not with-case) but fails to use either variable
> > when sorting and always sorts with case.
>
> IIRC, it was fixed in master branch. Could you test it?
>
> Thank you.
>
> Regards,
>
> --
> Nicolas Goaziou
>


[O] bug: org-table-sort-lines does only case sensitive alphabetical sorting

2018-07-03 Thread Heikki Lehvaslaiho
org-sort has an optional argument with-case. By default its sorting ignores
the case. When org-sort is called within a table, it calls
org-table-sort-line with the argument. org-table-sort-line defines a let
variable sort-fold-case (not with-case) but fails to use either variable
when sorting and always sorts with case.

This is with the very latest org:
Org mode version 9.1.13 (9.1.13-elpa @
/Users/helehvas/.emacs.d/elpa/org-20180702/)

 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki


Re: [O] Kanban board as an agenda view

2016-10-02 Thread Heikki Lehvaslaiho
Hi Eeli,

I started thinking along the same lines after reading the article and
thought to use it as a task to learn org table manipulation commands.

Unfortunately, I also found that my emacs has a problem that messes up
basic table cell copy or cut commands. See my post 'Cask-initialize messes
up org table manipulation commands' to this mailing list a few days ago. I
started planning and implementing an org-kanban-mode but stopped when I hit
this problem. I still have not solved it.

My idea was to have org-kanban as a minor mode that works on org mode
buffers. A defvar gives a default set of TODO keywords and the user can
configure any words into her own setup. Command org-kanban-write-keywords
writes the keywords to a '#+SEQ_TODO:' line at the top of the buffer and
makes sure there are no other '#+SEQ_TODO:' lines. This makes the keywords
buffer local and easy to modify. A function generates a named table with
current todo keywords. The user then fills up the table with tasks. A house
keeping function creates links of the task names, makes sure that there is
maximum one task on each line, and creates link targets with the correct
todo keyword. Ideally, there should be a function to update the table is
the keywords are changed, but that could be messy.

The org-kanban-mode also overrides the org table key bindings of M-
and M- to move cell contents, i.e. tasks, left and right. The
move-cell functions would also update the todo status of the lined header.

I have about 100 lines of code implementing some of the plan above that I
am happy to share. if you are interested, I could, for example, put the
code in a shared and GPL'd github repo, and you could take it from there.

Let me know,


 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki

On 27 September 2016 at 10:27,  wrote:

> Hello,
>
> I was inspired by this post[1], that describes a workflow that uses
> links and a table to organize tasks in columns like on a Kanban
> board[2].
>
> I started thinking if this kind of visualization could be done
> automatically by implementing a view like the agenda, that would use
> `org-todo-keywords' as column headings and layout TODO items from
> `org-agenda-files' into a columnar view.
>
> Is there any prior work on this, or is anyone willing to implement it?
> If not, could you kindly point me to the right direction, so I can start
> hacking?
>
> [1]:
> http://jr0cket.co.uk/2016/09/Kanban-board-Emacs-Org-mode-
> to-get-work-done.html
> [2]: https://en.wikipedia.org/wiki/Kanban_board
>
> Eeli
>
>


Re: [O] manipulate org tables using emacs-lisp

2016-10-02 Thread Heikki Lehvaslaiho
Hi Alan,

Try this function. You can test if the table was found before manipulating
it. Table functions typically work only inside tables, but the #+NAME line
is part of it although it is before the table itself (as defined by
function org-table-begin).


  (defun my/org-table-find-by-name (str)
"Move point to the first table of the buffer with STR in the name.

The point does not move if the table is not found.
Returns the new position if successful, nil otherwise.
"
(interactive "sTable name substring: ")
(let ((re (concat "#\\+NAME:.+" str))
  (loc-table nil))
  (setq loc-table (save-excursion
(goto-char (point-min))
(re-search-forward re nil t)))
  (if (number-or-marker-p loc-table)
  (goto-char loc-table

  -Heikki

Hi Thorsten,

>
> On 2016-09-30 22:52, Thorsten Jolitz  writes:
>
> >> Are there functions for manipulating org-tables using emacs-lisp? More
> >> precisely, I would like to refer to a table by its name, read some cells
> >> (either by position or by matching some given text with some text in the
> >> first row/column), and write in some cells.
> >
> > ,[ C-h f org-table-to-lisp RET ]
> > | org-table-to-lisp is an autoloaded compiled Lisp function in
> > | ‘../org-mode/lisp/org-table.el’.
> > |
> > | (org-table-to-lisp  TXT)
> > |
> > | Convert the table at point to a Lisp structure.
> > | The structure will be a list.  Each item is either the symbol ‘hline’
> > | for a horizontal separator line, or a list of field values as strings.
> > | The table is taken from the parameter TXT, or from the buffer at point.
> > |
> > | [back]
> > `
> >
> > returns the table as a nested list you can map with lots of Elisp
> > functions (like mapcar).
> >
> > Ex.:
> >
> > | my | tab |
> > |  1 |   2 |
> >
> > =>
> >
> > (("my" "tab") ("1" "2"))
>
> This is very useful, thank you. But how do I go to a named table? I
> found org-babel-goto-named-block, but nothing for tables.
>
> Thanks again,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
> Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-08: 402.25, 2015-08: 398.93
>


Re: [O] Cask-initialize messes up org table manipulation commands

2016-10-01 Thread Heikki Lehvaslaiho
Thanks for suggestions, Adam.

I had not realised that the bug-hunter package can do interactive tests. I
used it now and got the same result: the problem is caused by
the (cask-initialize) expression.

As far as I understand, cask-initialize only collects the directory
locations and dependencies of packages as a struct that is then processed
later during the emacs start-up. How that can mess up the org cursor
movement is a complete mystery to me.

I am using org mode and use-package to maintain, launch and configure my
packages. The culprit can not be the tangling process nor the launching of
the packages because they happens after cask is initialized (and bug-hunter
works on elisp file, only).

I did try emacs with the -q but did not see any difference to -Q.

The one piece of information that I did not include in my posting: My emacs
comes from homebrew git HEAD and is installed it with:

brew unlink emacs
brew uninstall emacs
brew install emacs --HEAD --use-git-head --with-cocoa --with-gnutls
--with-rsvg --with-imagemagick
brew linkapps

Maybe I should try raising an issue for cask (https://github.com/cask/cask).

Cheers,


 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki

On 29 September 2016 at 06:53, Adam Porter <a...@alphapapa.net> wrote:

> Heikki Lehvaslaiho <heikki.lehvasla...@gmail.com> writes:
>
> > The cell content disappears but to my surprise the cursor jumped out
> > of the table! Trying with different tables, it came clear that the
> > cursor always jumped one line down and left of the table). (Under the
> > left border if you have a box cursor.) That should not happen!
>
> This may not be much help, because I'm still using Org 8.2.4, but I
> tried and was unable to reproduce this; the cursor remains in the table.
>
> > The final twist to this story is that if I start emacs, create an org
> > buffer with a table, and run org-table-cut-region key combination
> > first before evaling the init.el content, the cursor behaviour does
> > not change even after cask has been initialized!
>
> You said you bisected your init file; I assume you used the bug-hunter
> package?  If by chance you did it manually instead, I would recommend
> doing it again with bug-hunter; maybe you made a tiny mistake that threw
> the whole thing off.  :)
>
> Since it doesn't happen with "emacs -Q", I guess it must be someting in
> your config.  (Though you might test with "emacs -q" also--there is a
> difference.)
>
> I don't use Cask, so I can't help you much there.  What follows is what
> may be considered an unhelpful suggestion, but it's the best idea I
> have: switch from Cask/Pallet to use-package; it may give you
> finer-grained control over your init file, and bisecting may work
> better.  I don't know remember how Cask works exactly, but if
> cask-initialize "monolithically" loads all the packages you have
> configured, I'm guessing you won't be able to bisect within it to figure
> out which package is causing the problem.
>
> Hope this helps.
>
>
>


[O] Cask-initialize messes up org table manipulation commands

2016-09-24 Thread Heikki Lehvaslaiho
* Problem

I wanted to script org mode table manipulations. The most basic table
command is org-table-cut-region (C-c C-x C-w)[fn:1].

I tried this with simplest possible table:

| x |

The cell content disappears but to my surprise the cursor jumped out
of the table! Trying with different tables, it came clear that the
cursor always jumped one line down and left of the table). (Under the
left border if you have a box cursor.) That should not happen!

Can anyone reproduce this?

* Clean run

Running bare emacs did not show this problem. The cursor stayed
between the cell borders.

#+BEGIN_SRC sh
/usr/local/bin/emacs -Q
#+END_SRC

* Cleaning emacs config

Assuming the culprit was some package in my emacs config, I bisected
my init file to almost nothing and still had the problem!

I am using Cask and pallet to keep track of the packages installed.

I removed all depends-on statements from my Cask file including the
one for pallet before I found the source of the problem.

The Cask file looks now like this:

#+BEGIN_EXAMPLE
(source gnu)
(source melpa)
(source org)

(depends-on "cask")
#+END_EXAMPLE

The init.el file was down to:

#+BEGIN_EXAMPLE
(package-initialize)
(require 'cask "/usr/local/share/emacs/site-lisp/cask/cask.el")
(cask-initialize)
#+END_EXAMPLE

If I remove the (cask-initialize) line, the cursor stays inside the
org table cell.

* Order matters

The final twist to this story is that if I start emacs, create an org
buffer with a table, and run org-table-cut-region key combination
first before evaling the init.el content, the cursor behaviour does
not change even after cask has been initialized!

What is going on here?

* Setup

I have recently compiled version 25.1 of emacs using homebrew
in my Mac. I regularly update emacs packages from melpa.
My current setup is:

#+BEGIN_EXAMPLE
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.6
BuildVersion: 15G31

M-x emacs-version
GNU Emacs 25.1.50.1 (x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version
10.11.6 (Build 15G31)) of 2016-09-18

M-x org-version
Org-mode version 8.3.6 (8.3.6-3-gf46b92-elpaplus @
/Users/lehvasho/src/emacs-literal-config/.cask/25.1/elpa/org-plus-contrib-20160919/)

$ cask --version
0.8.0
#+END_EXAMPLE

Incidentally, org-plus-contrib and plain org packages behave identically.

* Footnotes

[fn:1] The key binding actually calls org-cut-special that is a
context sensitive command. It calls org-table-cut-region only inside
table cells. (The org-cut-special document string has false
information claiming it calls org-table-copy.)


Re: [O] org-link-set-parameters missing in ELPA version

2016-09-02 Thread Heikki Lehvaslaiho
I've been experiencing similar problems with increasing annoyance level for
over a month. Thanks to these comments I think I got to the bottom of it!

The MELPA package org-mac-link (latest is org-mac-link-20160808.220) has
clearly continued being updated with new code that include calls to
org-link-set-parameters. The org-mac-link.el in package org-plus-contrib
has the code that works with org v8. Everyone who has been using MELPA,
especially with use-package, to load org-mac-link.el has not been using the
code in org-plus-contrib.

I removed the downloaded org-mac-link package files and the corresponding
depends-on line from my Cask file, and reverted to old require syntax to
load org-mac-link . Problem solved.


 -Heikki

Heikki Lehväslaiho - skype:heikki_lehvaslaiho cell: +358 40 850 6640
http://about.me/heikki

On 26 August 2016 at 04:31, Rob Duncan  wrote:
>
> Hi John,
>
> I deleted my existing packages and installed org-plus-contrib-20160822
and everything works again.
>
> Thanks very much!
>
> Rob.
>
> > On Aug 25, 2016, at 6:15 PM, John Kitchin 
wrote:
> >
> > I haven't been able to reproduce this in org-plus-contrib-20160822.
> >
> > Rob Duncan writes:
> >
> >> Hi John,
> >>
> >> My org is claiming to be version 8.3.5:
> >>
> >> Org-mode version 8.3.5 (8.3.5-elpa @
/Users/rduncan/.emacs.d/elpa/org-20160815/)
> >>
> >> Rob.
> >>
> >> On Aug 20, 2016, at 11:56 AM, John Kitchin > wrote:
> >>
> >> that seems weird, I thought that should only be in org 9. Is that on
ELPA somehow?
> >>
> >> John
> >>
> >> ---
> >> Professor John Kitchin
> >> Doherty Hall A207F
> >> Department of Chemical Engineering
> >> Carnegie Mellon University
> >> Pittsburgh, PA 15213
> >> 412-268-7803
> >> @johnkitchin
> >> http://kitchingroup.cheme.cmu.edu
> >>
> >>
> >> On Sat, Aug 20, 2016 at 2:45 PM, Rob Duncan  wrote:
> >> I just installed org-mac-link version 20160808.220 from ELPA and I’m
no longer able to insert links from Mail.app and other applications.  It
used to work…
> >>
> >> When I try to manually load org-mac-link.el I get this error message:
> >>
> >> eval-buffer: Symbol’s function definition is void:
org-link-set-parameters
> >>
> >> Did I mess up the install, or is the package broken somehow?
> >>
> >> Thanks,
> >>
> >> Rob.
> >
> >
> > --
> > Professor John Kitchin
> > Doherty Hall A207F
> > Department of Chemical Engineering
> > Carnegie Mellon University
> > Pittsburgh, PA 15213
> > 412-268-7803
> > @johnkitchin
> > http://kitchingroup.cheme.cmu.edu
>


[O] Controlling example block export?

2014-04-01 Thread Heikki Lehvaslaiho
I am using example blocks as inline notes where I paste snippets of
(pre-formatted) text. I'd like to  be able to control the exporting of
those block individually (per document would also be useful). I do not seem
to be able to find documentation about anything along those lines.

Here is a mock-up:

#+BEGIN_EXAMPLE :exports none
private notes...
#+END_EXAMPLE

A bigger question is that while code blocks are well defined and well
documented, all other blocks are not. Is there somewhere a design document
the would give a logic of having different blocks and how they are
controlled? Maybe there is an other type of a block that does what I want?

The inline documentation in ox*.el files is too low level to be helpful.


 -Heikki

Heikki Lehvaslaiho - skype:heikki_lehvaslaiho http://about.me/heikki
cell: +966 545 595 849  office: +966 12 808 2429

Saudi Arabian weekend is now Friday and Saturday.

KAUST Supercomputing Center, Building #1, Level 0, 0203-WS23
4700 King Abdullah University of Science and Technology (KAUST)
Thuwal 23955-6900, Kingdom of Saudi Arabia


Re: [O] Controlling example block export?

2014-04-01 Thread Heikki Lehvaslaiho
Thanks, Torsten. Very illuminating.


The org-syntax.html says of blocks:


#+BEGIN_NAME PARAMETERS
CONTENTS
#+END_NAME

NAME can contain any non-whitespace character.
PARAMETERS can contain any character other than new line, and can be
omitted.
If NAME is CENTER, it will be a center block. If it is QUOTE, it will
be a quote block.
If the block is neither a center block, a quote block or a block
elementhttp://orgmode.org/worg/dev/org-syntax.html#Blocks,
it will be a special block.

That does not seem to be quite true as lisp/org-element.el recognises the
following blocks (perlregexp: /begin_(\w+)/i):

- CENTER
- COMMENT
- EXAMPLE
- QUOTE
- SRC
- VERSE

... in addition to any other valid block names. For these, the content is
displayed as plain text after striping the BEGIN/END lines unless the
exporter used has code for handling it differently.

Note: org-syntax.html  needs updating.

So, to implement parameters for the EXAMPLE block, relevant code has to be
added to the exporter. That's a nontrivial task to do consistently.

Incidentally, the solution to my immediate problem is the COMMENT block.
Its contents are completely ignored and not passed to exporters. If I find
myself using that a lot, a macro or a a function to toggle between these
two might come handy:


#+BEGIN_COMMENT :type EXAMPLE
 text in a  block
#+END_COMMENT



#+BEGIN_ EXAMPLE
 text in a  block
#+END_EXAMPLE

Unless someone beats me to it, I'll write it one day. :)



 -Heikki

Heikki Lehvaslaiho - skype:heikki_lehvaslaiho http://about.me/heikki
cell: +966 545 595 849  office: +966 12 808 2429

Saudi Arabian weekend is now Friday and Saturday.

KAUST Supercomputing Center, Building #1, Level 0, 0203-WS23
4700 King Abdullah University of Science and Technology (KAUST)
Thuwal 23955-6900, Kingdom of Saudi Arabia


On 1 April 2014 13:10, Thorsten Jolitz tjol...@gmail.com wrote:

 Heikki Lehvaslaiho heikki.lehvasla...@gmail.com writes:

  I am using example blocks as inline notes where I paste snippets of
  (pre-formatted) text. I'd like to be able to control the exporting of
  those block individually (per document would also be useful). I do not
  seem to be able to find documentation about anything along those
  lines.
 
  Here is a mock-up:
 
  #+BEGIN_EXAMPLE :exports none
  private notes...
  #+END_EXAMPLE

 I don't think example blocks take arguments. You might try

 #+BEGIN_SRC org :exports none
  private notes...
 #+END_SRC

 or collect these example blocks in subtrees with export tags/properties.

  A bigger question is that while code blocks are well defined and well
  documented, all other blocks are not. Is there somewhere a design
  document the would give a logic of having different blocks and how
  they are controlled? Maybe there is an other type of a block that does
  what I want?
  The inline documentation in ox*.el files is too low level to be
  helpful.

 AFAIK export of these block types is backend specific, e.g. ox-ascii.el
 might treat example block different than ox-html.el, so thats where to
 look.

 ,---
 | C-h v org-export-with- TAB
 `---

 gives some hints too. Using drawers instead of example blocks would
 enable you to toggle export documentwise.

 I asked a similar 'bigger' question before, and remember that the answer
 was more or less 'the block name says it all'.

 However, here is a (dense) description of the org syntax:

 ,
 | http://orgmode.org/worg/dev/org-syntax.html
 `

 --
 cheers,
 Thorsten