Jag har en massa elisp-hack för liknande uppgifter jag gör på jobbet. Emacs
rular! ;)

/Mathias

On Thu, Nov 13, 2014 at 12:25 PM, Lars Brinkhoff <l...@nocrew.org> wrote:

>
>
> Nu har jag det.
>
> Istället för att göra ett hack i shell, gjorde jag följande för att
> konvertera radslut till CRLF i Emacs.  Jag vet att det finns unix2dos
> och liknande, men jag ville ha lite mer kontroll på hantering av
> binära filer m m.
>
> (defun map-files (fn dir)
>   "Apply function FN to all files in DIR, including subdirectories.
> The function is called with a file loaded into a buffer, which is saved
> when the function returns.  Doesn't descend into the .hg subdirectory."
>   (dolist (i (directory-files dir t))
>     (unless (member (file-name-nondirectory i) '("." ".." ".hg"))
>       (if (file-directory-p i)
>           (map-files fn i)
>           (with-current-buffer (find-file-noselect i)
>             (funcall fn)
>             (when (buffer-modified-p)
>               (save-buffer))
>             (kill-buffer))))))
>
> (defun set-buffer-crlf ()
>   (when (eql (coding-system-eol-type buffer-file-coding-system) 0)
>     (let ((coding (coding-system-change-eol-conversion
>                    buffer-file-coding-system 1)))
>       (when coding
>         (set-buffer-file-coding-system coding)))))
>
> (defun convert-to-crlf ()
>   "Convert all files to CRLF line endings."
>   (map-files #'set-buffer-crlf "/foo/bar/baz"))
>
>
> _______________________________________________
> Lisp mailing list
> Lisp@lisp.se
> http://mailman.nocrew.org/cgi-bin/mailman/listinfo/lisp
>
_______________________________________________
Lisp mailing list
Lisp@lisp.se
http://mailman.nocrew.org/cgi-bin/mailman/listinfo/lisp

Till