Groups | Search | Server Info | Login | Register
Groups > gnu.emacs.help > #61040
| From | Jens Thiele <karme@karme.de> |
|---|---|
| Newsgroups | gnu.emacs.help |
| Subject | Really strange problem with arc-mode.el |
| Date | 2025-10-04 09:59 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <10bqk4b$2bfj4$1@dont-email.me> (permalink) |
Hi,
I want to add an archive format to emacs. It would work if the magic
bytes wouldn't start with "M" :-)
Now I tried to track down the problem and made up a fake archive format.
I have a test script that should complete without error:
;; testing a problem with archive-mode where the archive has a M as
;; first magic byte
(require 'arc-mode)
(defun archive-mv-summarize (&optional file)
(unless file
(setq file buffer-file-name))
(let ((copy (file-local-copy file))
(files ()))
(with-temp-buffer
(insert-file (or file copy))
(when copy (delete-file copy))
(goto-char (point-min))
(search-forward-regexp "^(")
(beginning-of-line)
(let ((alist (read (current-buffer))))
(mapc (lambda(x)
(let ((fname (symbol-name (car x)))
(fsize (string-width (cdr x))))
(push (archive--file-desc fname fname nil fsize
"1984-01-01 00:00")
files)))
alist)))
(archive--summarize-descs (nreverse files))))
;; unfortunately there is no hook => use advice-add
(defun archive-find-type-mv-around (oldfun)
(widen)
(goto-char (point-min))
;; NOTE: the problem only occurs if the magic bytes start with M
(cond ((looking-at "MV") 'mv)
(t (funcall oldfun))))
(advice-add 'archive-find-type :around #'archive-find-type-mv-around)
(add-to-list 'auto-mode-alist '("\\.mv$" . archive-mode))
(add-to-list 'auto-coding-alist '("\\.mv$" . no-conversion))
(with-temp-buffer
(insert "MV\n")
(insert "((a . \"foo\") (b . \"bar\"))\n")
(write-file "/tmp/test.mv"))
(with-current-buffer (find-file-noselect "/tmp/test.mv" nil nil nil)
(revert-buffer))
But running it like this:
$ emacs -nw -Q --no-init --script ./arc-mv.el
It fails with:
Buffer format not recognized
NOTE!: if you change the magic bytes from "MV" to something like "EV" it
works as expected.
I would really appreciate some help there, thanks!
Jens Thiele
Back to gnu.emacs.help | Previous | Next — Next in thread | Find similar
Really strange problem with arc-mode.el Jens Thiele <karme@karme.de> - 2025-10-04 09:59 +0200 Re: Really strange problem with arc-mode.el Jens Thiele <karme@karme.de> - 2025-10-06 09:18 +0200
csiph-web