emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vegard Vesterheim <vegard.vesterheim@uninett.no>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: orgtbl-mode and markdown
Date: Tue, 18 Dec 2012 14:39:54 +0100	[thread overview]
Message-ID: <1sbodrbhsl.fsf@voll.uninett.no> (raw)
In-Reply-To: <D42C4820-A0C0-4721-8081-0E496A7395A0@gmail.com> (Carsten Dominik's message of "Tue, 18 Dec 2012 14:07:36 +0100")

On Tue, 18 Dec 2012 14:07:36 +0100 Carsten Dominik <carsten.dominik@gmail.com> wrote:

> On 18 dec. 2012, at 09:33, Vegard Vesterheim <vegard.vesterheim@uninett.no> wrote:
>
>> I had problems editing tables (using the minor mode orgtbl-mode) in
>> markdown files. 
>> 
>> To reproduce: 
>> - visit an empty buffer in markdown mode
>> - M-x orgtbl-mode
>> - create a new table (C-c |)
>> - try to edit a cell
>> - observe that the edited text is misplaced at the end of the line
>> 
>> The following patch against 709bf92950fb3e9dd7425e01eb53eedad43c7262
>> seems to fix the problem
>> 
>> diff --git a/lisp/org-table.el b/lisp/org-table.el
>> index acad0bb..188a825 100644
>> --- a/lisp/org-table.el
>> +++ b/lisp/org-table.el
>> @@ -4233,10 +4233,10 @@ overwritten, and the table is not marked as requiring realignment."
>> 	    t)
>> 	   (eq N 1)
>> 	   (looking-at "[^|\n]*  +|"))
>> -      (let (org-table-may-need-update)
>> -	(goto-char (1- (match-end 0)))
>> -	(backward-delete-char 1)
>> -	(goto-char (match-beginning 0))
>> +      (let ((org-table-may-need-update) (mb (match-beginning 0)) (me (match-end 0)))
>> +	(goto-char (1- me))
>> +	(delete-backward-char 1)
>> +	(goto-char mb)
>> 	(self-insert-command N))
>>     (setq org-table-may-need-update t)
>>     (let* (orgtbl-mode
>
>
> This is really strange.  Does markdown mode define hooks which kick in
> on delete-backward-char and which to bad stuff with the match data?

Dunno. I just observed that (match-end 0) returned different results
immediately before and after (backward-delete-char 1). 

> Looks to me that this is a bug in markdown-mode, which should be
> reported to its authors.

Possibly, I am not proficient in elisp, hence the naive patch. But isn't
it good practise to copy the match positions immediately after matching
anyways? 

 - Vegard V -

  reply	other threads:[~2012-12-18 13:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18  8:33 orgtbl-mode and markdown Vegard Vesterheim
2012-12-18 13:07 ` Carsten Dominik
2012-12-18 13:39   ` Vegard Vesterheim [this message]
2012-12-18 14:50     ` Carsten Dominik
2012-12-18 17:56       ` Achim Gratz
2012-12-20  8:01         ` Carsten Dominik
2012-12-21 10:53           ` Carsten Dominik
2012-12-23 16:33             ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1sbodrbhsl.fsf@voll.uninett.no \
    --to=vegard.vesterheim@uninett.no \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).