Bug 1030391

Summary: Switching script mode to rpm puts nonsense on the first line
Product: [Fedora] Fedora Reporter: Vratislav Podzimek <vpodzime>
Component: emacsAssignee: Jan Synacek <jsynacek>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: jonathan.underwood, ovasik, phracek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-06 07:56:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vratislav Podzimek 2013-11-14 11:02:14 UTC
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):
emacs-24.3-13.fc20.x86_64

How reproducible:
100 %

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

Actual results:
#!/usr/bin/rpm

Expected results:
nothing added to the first line

Comment 1 Petr Hracek 2015-03-04 11:39:13 UTC
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))
			      auto-mode-alist))
(defun my-rpm-changelog-increment-version()
  (interactive)
  (goto-char (point-min))
  (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))
       ))

Comment 2 Vratislav Podzimek 2015-05-19 08:14:17 UTC
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.

Comment 3 Vratislav Podzimek 2015-05-19 08:18:00 UTC
Where does the rpm-spec-mode.el file come from? Cannot find it on my system.

Comment 4 Petr Hracek 2015-05-22 07:49:41 UTC
It is separate package emacs-rpm-spec-mode-0.15-2.fc21.noarch

Comment 5 Petr Hracek 2015-05-22 11:07:07 UTC
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?

Comment 6 Vratislav Podzimek 2015-05-25 15:26:06 UTC
(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.

Comment 7 Fedora End Of Life 2015-05-29 09:45:32 UTC
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'
of '20'.

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.

Comment 8 Vratislav Podzimek 2015-06-10 07:26:43 UTC
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.

Comment 9 Petr Hracek 2015-07-02 09:41:37 UTC
Finally I have reproduce it.

Bug is reported to the upstream https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20959

Comment 10 Petr Hracek 2015-07-17 12:04:45 UTC
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.

Comment 11 Fedora Admin XMLRPC Client 2015-12-15 11:27:13 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 12 Jan Synacek 2016-01-06 07:56:59 UTC
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.