Bug 1030391 - Switching script mode to rpm puts nonsense on the first line
Switching script mode to rpm puts nonsense on the first line
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: emacs (Show other bugs)
22
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jan Synacek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-14 06:02 EST by Vratislav Podzimek
Modified: 2016-01-06 02:56 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-06 02:56:59 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Vratislav Podzimek 2013-11-14 06:02:14 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):
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 06:39:13 EST
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 04:14:17 EDT
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 04:18:00 EDT
Where does the rpm-spec-mode.el file come from? Cannot find it on my system.
Comment 4 Petr Hracek 2015-05-22 03:49:41 EDT
It is separate package emacs-rpm-spec-mode-0.15-2.fc21.noarch
Comment 5 Petr Hracek 2015-05-22 07:07:07 EDT
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 11:26:06 EDT
(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 05:45:32 EDT
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 03:26:43 EDT
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 05:41:37 EDT
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 08:04:45 EDT
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 06:27:13 EST
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 02:56:59 EST
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.

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