Bug 631707 - Xemacs incorrectly detects perl programs as statistical scripts (ESS)
Summary: Xemacs incorrectly detects perl programs as statistical scripts (ESS)
Alias: None
Product: Fedora
Classification: Fedora
Component: emacs-common-ess
Version: 13
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Alex Lancaster
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2010-09-08 08:40 UTC by Simon Andrews
Modified: 2010-10-28 05:57 UTC (History)
3 users (show)

Fixed In Version: emacs-common-ess-5.11-2.fc14
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-10-27 22:37:08 UTC
Type: ---

Attachments (Terms of Use)
Perl program which illustrates the problem (92 bytes, application/octet-stream)
2010-09-08 08:40 UTC, Simon Andrews
no flags Details

Description Simon Andrews 2010-09-08 08:40:14 UTC
Created attachment 445922 [details]
Perl program which illustrates the problem

Description of problem:
Opening a perl program without a .pl extension, but with a correct #! line causes xemacs to open in ESS mode.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Create a small perl program without a .pl extension on the filename
2. xemacs perl_program
Actual results:
Xemacs opens in ESS mode rather than perl mode, with odd effects on the keyboard (underscores produce arrows etc).

Expected results:
Preferably, xemacs opens in perl mode, but if not then generic text mode.

Additional info:
This bug doesn't seem to affect emacs hence filing under xemacs.

The bug persists even after deleting .xemacs and .xemacs.d and occurs in multiple user accounts.

Comment 1 Jerry James 2010-09-09 03:50:53 UTC
Do you have xemacs-packages-extra installed?  The Perl support is in there.  For me, opening your attached file produces a buffer in CPerl-mode.

Comment 2 Simon Andrews 2010-09-09 07:38:09 UTC
Yes, my installed xemacs packages are:

$ rpm -qa | grep xemacs

Using the file I attached previously, if I do:

xemacs perltest

..I get ESS mode but if I do 

cp perltest perltest.pl
xemacs perltest.pl

I get perl mode.

Playing some more I find that if I remove


then xemacs perltest opens in perl mode again.

So I guess it's a combination of xmeacs and the xemacs-ess package which trigger this.

Comment 3 Jerry James 2010-09-10 03:04:17 UTC
Yup.  After starting XEmacs with the xemacs-ess package installed, interpreter-mode-alist contains this gem:

("r" . r-mode)

which comes from line 266 of /usr/share/xemacs/site-packages/lisp/ess/ess-site.el(c), which is loaded unconditionally by /usr/share/xemacs/site-packages/lisp/site-start.d/ess-init.el.  That's right.  Anything containing the letter 'r' on the interpreter line now gets r-mode, which precedes the rule for perl-mode in the list.  So this line:


contains an 'r', therefore you must want r-mode, right?

That's broken in multiple ways.  First, just installing the xemacs-ess package should not unconditionally activate it for every user of the machine where it is installed.  Make the users who want this mode add (require 'ess-site) to ~/.xemacs/init.el and get rid of the file in site-start.d.  Second, "r" is a totally unreasonable regular expression.  Should that be "^r$" or "^R$", perhaps?

Reassigning to the emacs-common-ess package.

Comment 4 Jerry James 2010-10-10 03:30:01 UTC
Hello?  Anybody home?  I'd like to see this fixed so I don't get more bug reports about it.

Comment 5 Alex Lancaster 2010-10-15 05:37:46 UTC
(In reply to comment #4)
> Hello?  Anybody home?  I'd like to see this fixed so I don't get more bug
> reports about it.

I'll have a look into it soon.  That actually comes from the original upstream package, but I agree that's a bad choice for the regex and it needs to be fixed.  I'll fix it locally and then report it upstream.

Comment 6 Alex Lancaster 2010-10-15 19:12:50 UTC
Hmm, don't get this issue with GNU Emacs, so seems to be xemacs specific.  Also just installed xemacs-ess to try to duplicate it by loading a .pl script with 

#!/usr/bin/perl -w

in the header and it appears to do the right thing (i.e. load Perl mode) and loads R mode for files with .r as extension.  Can you attach some .pl and .r files that can reproduce this error?  Thanks.

Comment 7 Simon Andrews 2010-10-15 19:21:52 UTC
There is already a script attached to this job which exhibited the problem on my system and which was used to reproduce this by the xemacs maintainer.  I also found that this was xemacs specific as the problem didn't occur in regular emacs.

Comment 8 Alex Lancaster 2010-10-15 19:24:43 UTC
Oops, sorry just saw the attachment in comment #0.  I can now reproduce the issue with xemacs but GNU Emacs does the right thing.

Comment 9 Alex Lancaster 2010-10-15 19:45:20 UTC
OK, I have patched the package with a workaround to use "r$" as a regex.  It seems to work locally, builds for updates-testing will be on their way soon, meanwhile I have reported the issue upstream as well (will post link to thread on upstream ML once it is moderated).

Comment 10 Fedora Update System 2010-10-15 21:18:20 UTC
emacs-common-ess-5.11-2.fc14 has been submitted as an update for Fedora 14.

Comment 11 Fedora Update System 2010-10-15 21:20:31 UTC
emacs-common-ess-5.11-2.fc13 has been submitted as an update for Fedora 13.

Comment 12 Fedora Update System 2010-10-17 04:49:43 UTC
emacs-common-ess-5.11-2.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update emacs-common-ess'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/emacs-common-ess-5.11-2.fc13

Comment 13 Alex Lancaster 2010-10-18 20:44:33 UTC
Also reported upstream:


Comment 14 Fedora Update System 2010-10-27 22:37:03 UTC
emacs-common-ess-5.11-2.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2010-10-28 05:57:22 UTC
emacs-common-ess-5.11-2.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.