How can I apply a new Emacs C style to reformat all my source files?

前端 未结 4 2190
心在旅途
心在旅途 2020-12-31 21:08

I\'d like to re-format all my source files using the Google formatting function for emacs: google-c-style.el (see here).

How can I apply this function to all my sour

4条回答
  •  天涯浪人
    2020-12-31 21:27

    If you want to mark the source files in a dired buffer and then run a function to format each you can do something like this:

    (defun clean-file(filename)
      (your-function-goes-here))
    
    (defun clean-each-dired-marked-file() 
      (interactive)
      (for-each-dired-marked-file 'clean-file))
    
    (defun for-each-dired-marked-file(fn)
     "Do stuff for each marked file, only works in dired window"
     (interactive)
     (if (eq major-mode 'dired-mode)
         (let ((filenames (dired-get-marked-files)))
           (mapcar fn filenames))
       (error (format "Not a Dired buffer \(%s\)" major-mode))))
    

提交回复
热议问题