Red Hat Bugzilla – Bug 1030391
Switching script mode to rpm puts nonsense on the first line
Last modified: 2016-01-06 02:56:59 EST
Description of problem:
When switching to the RPM script mode used for editting spec files, emacs puts '#!/usr/bin/rpm' on the first line of the buffer.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. run file not ending with .spec (e.g. something.spec.in)
2. use 'C-c :' 'rpm' to switch to the RPM mode
3. go to the first line of the buffer
nothing added to the first line
What do you have in your .emacs file?
I have tried it on Fedora 21 where is emacs-24.4 and all forks fine.
My .emacs file looks like:
(autoload 'rpm-spec-mode "rpm-spec-mode.el" "RPM spec mode." t)
(setq auto-mode-alist (append '(("\\.spec" . rpm-spec-mode))
(let * ((max (search-forward-regexp rpm-section-regexp))
(version (rpm-spec-field-value "Version" max)))
(rpm-add-change-log-entry (concat "Upgrade version to " version))
I don't have the "RPM spec mode" hooked up. The result is that the shell-script-mode is turned on on .spec files with shell set to 'rpm'. However, if I open a .spec.in file (to be processed by autoconf), shell-script-mode is turned on too, but as 'bash'. If I do 'sh-set-shell' 'rpm' later, '#!/usr/bin/rpm' is added to the first line.
Where does the rpm-spec-mode.el file come from? Cannot find it on my system.
It is separate package emacs-rpm-spec-mode-0.15-2.fc21.noarch
On my F22 I am not able to reproduce it.
I erased emacs-rpm-spec-mode package and tried to edit some spec.in file all works fine.
Where RPM mode comes from? It is a part of emacs? I did not find any plugin like you mention.
Do you have any reference to RPM script mode?
(In reply to Petr Hracek from comment #4)
> It is separate package emacs-rpm-spec-mode-0.15-2.fc21.noarch
Thanks, I'll give it a try.
(In reply to Petr Hracek from comment #5)
> On my F22 I am not able to reproduce it.
> I erased emacs-rpm-spec-mode package and tried to edit some spec.in file all
> works fine.
> Where RPM mode comes from? It is a part of emacs? I did not find any plugin
> like you mention.
> Do you have any reference to RPM script mode?
It's just the shell-script-mode with the shell set to 'rpm'. That's what .spec files are opened with in my Emacs without the rpm-spec-mode. If you open an existing .spec file, it works fine. But if you create a new one as 'emacs /tmp/test.spec' and then want to set the mode with 'shell-script-mode' followed by 'sh-set-shell' 'rpm', the invalid first line is added. Another case is if you e.g. open a .spec.in file which is not recognized as a .spec file and then switch to the shell-script-mode with the rpm set as shell.
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora 'version'
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.
Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 20 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Still the same even on F22. And I now realized there's one more bug -- the 'sh-set-shell' invocation also changes the permissions of the file, so the .spec file becomes executable after saving.
Finally I have reproduce it.
Bug is reported to the upstream https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20959
Upstream said that you can type
M-: (sh-set-shell "rpm" nil nil)
See bugreport in upstream.
But upstream suggest the create a list of hard-coded list which aren't really shells like rpm.
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
This is no bug. If you open something.in, you are automatically switched into shell-script-mode. By calling "C-c : rpm" (sh-set-shell), you are simply switching your shell interpreter from whatever you have set as default to "rpm", which is not what you want. If you want to edit spec files, install emacs-rpm-spec-mode and then use rpm-spec-mode.