In markdown-mode, some emacs features misbehave, sometimes emacs crashes.

Bug #1097845 reported by Stéphane Gourichon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
emacs-goodies-el (Ubuntu)
New
Undecided
Unassigned

Bug Description

# Context

Using emacs in markdown-mode.

# Affected features

* search-and-replace misses some occurrences
* sometimes downcase-word and capitalize-word operate on a wrong region (correct size but off by several characters)
* sometimes dabbrev-expand is affected, too, in a similar way
* query-replace sometimes causes emacs to crash

# How to reproduce

* Install Ubuntu 12.10 (or 12.04).
* sudo apt-get install emacs emacs-goodies-el
* Launch emacs (e.g. Alt-F2, type emacs, press Enter).
* In scratch buffer, type some multi-line text. For example : C-U 32 A, Enter, Up, C-K, C-K, then press C-Y 8 times.
* Buffer contains this :

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* Go to top of buffer.
* Run query-replace (e.g. Esc-%), type a, press Enter, type b, press Enter, press "!"
* See all A turned into B as expected

;; This buffer is for notes you don't wbnt to sbve, bnd for Lisp evblubtion.
;; If you wbnt to crebte b file, visit thbt file with C-x C-f,
;; then enter the text in thbt file's own buffer.

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

* Undo (C-_)
* M-x markdown-mode
* Go to top of buffer.
* Run same query-replace (e.g. Esc-%), press Enter, press "!"

## Expected behavior

Replacement has same behavior in markdown-mode as in any other mode (see above).

## Observed behavior

Replacement only operates on the first occurrence of each line.

;; This buffer is for notes you don't wbnt to save, and for Lisp evaluation.
;; If you wbnt to create a file, visit that file with C-x C-f,
;; then enter the text in thbt file's own buffer.

bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* Undo (C-_)

You can go back to any other mode (fundamental-mode, lisp-interaction-mode, text-mode) they do not exhibit the bug.

## Variant of query-replace failure : replacing patterns containing a line feed

* undo to get back to original content with all A
* M-x text-mode (or any other major mode)
* Go to top of buffer.
* Run query-replace (e.g. Esc-%), C-q C-j, Enter, C-q C-j > (space), press Enter, press "!"
* See every lines prefixed with "> " as expected.

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
> ;; If you want to create a file, visit that file with C-x C-f,
> ;; then enter the text in that file's own buffer.
>
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>

Now try same thing in markdown-mode:

* Undo (C-_)
* M-x markdown-mode
* Go to top of buffer.
* Run same query-replace (e.g. Esc-%), press Enter, press "!"

## Expected behavior

Replacement has same behavior in markdown-mode as in any other mode (see above).

## Observed behavior

Replacement misses every over line.

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
> ;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
>
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

You can observe similar behavior when using a pattern that replaces one line feed with two line feeds.
Oh, testing it again just crashed my emacs now! I let apport report it but it does not provide me a reference to the crash.

## Additional information

* Could not find an easy reproducible case for downcase-word and capitalize-word or for emacs crashes. Since a crash occurs, actual problem may lies in emacs instead of emacs-goodies-el ?
* Tested from a newly created user account to isolate from any custom emacs init files.
* Same problem happens on 12.04 and 12.10.
* On 12.04 same problem happens with stock emacs from distribution (emacs23) and with emacs24.

1) The release of Ubuntu you are using, via 'lsb_release -rd' or System -> About Ubuntu

$ lsb_release -rd
Description: Ubuntu 12.10
Release: 12.10

2) The version of the package you are using, via 'apt-cache policy pkgname' or by checking in Software Center

$ LC_ALL=C apt-cache policy emacs-goodies-el
emacs-goodies-el:
  Installed: 35.2ubuntu2
  Candidate: 35.2ubuntu2
  Version table:
 *** 35.2ubuntu2 0
        500 http://fr.archive.ubuntu.com/ubuntu/ quantal/main amd64 Packages
        100 /var/lib/dpkg/status

3) What you expected to happen
4) What happened instead

See long explanation above.

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: emacs-goodies-el 35.2ubuntu2
ProcVersionSignature: Ubuntu 3.5.0-21.32-generic 3.5.7.1
Uname: Linux 3.5.0-21-generic x86_64
ApportVersion: 2.6.1-0ubuntu9
Architecture: amd64
Date: Wed Jan 9 17:33:16 2013
InstallationDate: Installed on 2012-12-27 (13 days ago)
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
MarkForUpload: True
PackageArchitecture: all
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=fr_FR.UTF-8
 SHELL=/bin/bash
SourcePackage: emacs-goodies-el
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Stéphane Gourichon (stephane-gourichon-lpad) wrote :
description: updated
Revision history for this message
Stéphane Gourichon (stephane-gourichon-lpad) wrote :

Package: emacs-goodies-el 35.2ubuntu2 contains markdown-mode.el unmodified from upstream version: 1.8.1 as can be verified :

$ wget -q http://jblevins.org/projects/markdown-mode/markdown-mode.el -O - | diff -sq /usr/share/emacs/site-lisp/emacs-goodies-el/markdown-mode.el -
Files /usr/share/emacs/site-lisp/emacs-goodies-el/markdown-mode.el and - are identical

Revision history for this message
Stéphane Gourichon (stephane-gourichon-lpad) wrote :

Short version:
* upstream bug existed, now fixed in git but not released
* in the meantime use version from git
* bug should propagate to Ubuntu package eventually

Long version:

I now use version from today's git and confirm it fixes the bug.

From upstream author Jason Blevins:

> Thank you very much for letting me know about the report. Indeed, this is a known issue with markdown-mode 1.8.1. It was fixed in the development version, which is available here:
>
> http://jblevins.org/git/markdown-mode.git

> Emacs has never crashed on me
> as a result of this, but there were many unusual search and replace
> issues that were fixed by the following patch:
>
> http://jblevins.org/git/markdown-mode.git/commit/?id=eacccad35ac424916c2f44dac178c7d91894f17b

> I always notify the Debian emacs-goodies-el maintainer when I do so [release a stable version], in which case I believe
it should make its way into Ubuntu.

Revision history for this message
Stéphane Gourichon (stephane-gourichon-lpad) wrote :

Perhaps the crash that sometimes happens to emacs using markdown-mode 1.8.1 *is* itself a bug in emacs.
I won't open a launchpad bug for that crash, but if you feel there should be one, please open one.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.