[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
po-mode.el: po-check-file-header always inserts header in Emacs 23
From: |
Sven Joachim |
Subject: |
po-mode.el: po-check-file-header always inserts header in Emacs 23 |
Date: |
Wed, 13 Aug 2008 19:57:07 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Hi,
in current Emacs CVS, loading a PO file always inserts an extra header
at the beginning of the buffer, even if there is already one. I tracked
this misbehavior down to a changed semantic of the previous-line (and
next-line) function in Emacs, which by default now moves by display
lines:
,----[ C-h f previous-line ]
| previous-line is an interactive compiled Lisp function in `simple.el'.
|
| It is bound to <up>, C-p.
|
| (previous-line &optional arg try-vscroll)
|
| Move cursor vertically up arg lines.
| Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
| If there is no character in the target line exactly over the current column,
| the cursor is positioned after the character in that line which spans this
| column, or at the end of the line if it is not long enough.
|
| If the variable `line-move-visual' is non-nil, this command moves
| by display lines. Otherwise, it moves by buffer lines, without
| taking variable-width characters or continued lines into account.
|
| The command C-x C-n can be used to create
| a semipermanent goal column for this command.
| Then instead of trying to move exactly vertically (or as close as possible),
| this command moves to the specified goal column (or as close as possible).
| The goal column is stored in the variable `goal-column', which is nil
| when there is no goal column.
|
| If you are thinking of using this in a Lisp program, consider using
| `forward-line' with a negative argument instead. It is usually easier
| to use and more reliable (no dependence on goal column, etc.).
`----
The statement in the last paragraph is also true in Emacs 22 and 21, so
the following patch seems to be safe:
2008-08-13 Sven Joachim <address@hidden>
* po-mode.el (po-check-file-header): Use forward-line with
negative argument instead of previous-line.
(po-add-attribute): Use forward-line instead of next-line.
--8<---------------cut here---------------start------------->8---
--- po-mode.el.~1.42.~ 2008-05-25 13:18:51.000000000 +0200
+++ po-mode.el 2008-08-13 19:45:38.000000000 +0200
@@ -1342,7 +1342,7 @@
(progn
;; There is at least one entry.
(goto-char (match-beginning 0))
- (previous-line 1)
+ (forward-line -1)
(setq end-of-header (match-end 0))
(if (looking-at "msgid \"\"\n")
;; There is indeed a PO file header.
@@ -1352,7 +1352,7 @@
;; This is an oldish header. Replace it all.
(goto-char end-of-header)
(while (> (point) (point-min))
- (previous-line 1)
+ (forward-line -1)
(insert "#~ ")
(beginning-of-line))
(beginning-of-line)
@@ -1498,7 +1498,7 @@
(insert ", " name)))
(skip-chars-forward "\n")
(while (eq (following-char) ?#)
- (next-line 1))
+ (forward-line 1))
(insert "#, " name "\n")))))
(defun po-delete-attribute (name)
--8<---------------cut here---------------end--------------->8---
Cheers,
Sven
- po-mode.el: po-check-file-header always inserts header in Emacs 23,
Sven Joachim <=