std_comment.el: broken code for timestamp in Makefile

Bug #246354 reported by Stephan Fabel
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
emacs-extra (Ubuntu)
Confirmed
Undecided
Unassigned
Nominated for Intrepid by Stephan Fabel

Bug Description

When creating a new Makefile by visiting a new file, a template of a Makefile is automatically inserted by Emacs. Included is a timestamp that will update as the file is saved. However, it deletes the comment sign while updating, thus causing the successive 'make' call to fail.

For example, this is how the Makefile lines 7 and 8 look like before a save, when visiting the new file:
## Started on Mon Jul 7 08:07:04 2008 Stephan Fabel
## Last update Mon Jul 7 08:07:04 2008 Stephan Fabel

After the save, it looks like this:
## Started on Mon Jul 7 08:07:04 2008 Stephan Fabel
Last update Mon Jul 7 08:08:06 2008 Stephan Fabel

There is no way other than deleting line 8 to circumvent this behavior.

------------------------------------------------------------------------------------------

This problem can be solved by fixing bug in

/usr/share/emacs-extra/misc/std_comment.el

One should find function "update-std-header ()". In this function there is a line

(insert-string (concat(std-get 'cc)

that should be changed to

(insert-string (concat (std-get 'cc)

irb6 (lmalek)
description: updated
description: updated
summary: - Timestamp in Makefile
+ [SOLVED] Timestamp in Makefile
Revision history for this message
era (era) wrote : Re: [SOLVED] Timestamp in Makefile

This is not a bug in emacs22. The path name /usr/share/emacs-extra/misc/std_comment.el indicates the emacs-extra package as the likely culprit.

affects: emacs22 (Ubuntu) → emacs-extra (Ubuntu)
summary: - [SOLVED] Timestamp in Makefile
+ std_comment.el: broken code for timestamp in Makefile
Revision history for this message
era (era) wrote :

In order to reproduce this, you need to enable "Templates support" and "Automatique [sic] timestamp update" when installing emacs-extra (or enable these options at run-time; I assume there is a way to do that, although the general impression of the quality of this package will make you take few things for granted, and disinclined to investigate any further). But with that, I can duplicate at any time, so marking as confirmed.

Changed in emacs-extra (Ubuntu):
status: New → Confirmed
Revision history for this message
era (era) wrote :

The proposed patch does not appear to solve the issue for me. The syntax error is certainly an error, but correcting it does not cause the reported problem to go away.

(Jaunty live CD, emacs22, emacs-extra 0.1)

Revision history for this message
era (era) wrote :

When opening a Makefile, the default mode is GNUmakefile-mode. Manually switching to M-x makefile-mode works around the problem that std_header.el does not have the correct settings for GNUmakefile-mode. The syntax error in std_comment.el does not seem to affect this at all.

It seems mildly confusing and inconsistent that the general template code for Makefiles is activated even in GNUmakefile-mode, but that the comment lead-in character sequence for the time stamp is not defined in GNUmakefile-mode. Perhaps there is a problem in how GNUmakefile-mode inherits from makefile-mode, rather than in emacs-extra, although my bets would be on the latter.

Revision history for this message
claudel (claude-kuratorn) wrote :

I get identical problems when opening latex documents. The %% comments in front of the Last update lines
is eaten by the macro that changes the time. This is not the case for bash scripts for instance.

This could be related to my emacs setup but the template feature just appeared automagically when I install
the emacs-extra package which seemed a good idea.

My version of emacs-extra is 0.1-1ubuntu1. The fix described above is included in my distribution, it seems, but
the problem seems to be in the std-modes-alist definition. Here, both the GNUmakefile and the LaTeX/M major
modes are missing. Adding

 ("GNUmakefile" . std-makefile-alist)
("LaTeX/M" . std-tex-alist)

 However, one can certainly think of many more modes which may not be listed. It is not clear
to me how one would automate the creation of this list. The problem however seems to be on the side of the
std_comment.el package maintainer. The last update on that file is from 2006 though. An ubuntu patch for this
package? Or maybe a user configurable variable. If so, how to communicate to the user that his/her mode is
not listed in std-modes-alist?

Revision history for this message
Paul Huygen (paul-huygen) wrote :

It seems that the value of "kill-whole-line" may cause the update function to eat the lines following the "last update" line.
If this value is non-nil. the update function kills the "last update" line including the end-of-line character and generates a new "last update" line as a prefix to the following line.

Unfortunately I do not know enough of e-lisp to be able to fix this.

Thanks,

Paul Huygen

Revision history for this message
Paul Huygen (paul-huygen) wrote :

The following modification seems to fix the problem that I described in previous message:

In the function definition of "update-std-header" in file "std_comment.el", replace the lines:

 (kill-line)
 (rotate-yank-pointer 1)

by:
                (let ((beg (point)))
                   (forward-line 1)
                   (forward-char -1)
                   (delete-region beg (point)))

(I found these lines in <http://www.emacswiki.org/emacs/ElispCookbook#toc15>).

As a side affect, the old "last update" line will no longer be included into the kill ring.

Thanks,

Paul Huygen

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.