* 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.)