Re: [PPL-devel] Any emacs guru out there?
Is there a simple way, in emacs, to require spell-checking of all the comments and/or all the strings in C/C++ source files?
What's wrong with "M-x ispell-comments-and-strings"? Yours, Andrea.
Andrea Pescetti wrote:
Is there a simple way, in emacs, to require spell-checking of all the comments and/or all the strings in C/C++ source files?
What's wrong with "M-x ispell-comments-and-strings"?
It is near to perfect. What I would love to have is something like "M-x dired-do-ispell-comments-and-strings". I am sure there is a simple way to do it, but I don't know how. Ciao, Roberto -- Prof. Roberto Bagnara Computer Science Group Department of Mathematics, University of Parma, Italy http://www.cs.unipr.it/~bagnara/ mailto:bagnara@cs.unipr.it
What's wrong with "M-x ispell-comments-and-strings"?
It is near to perfect. What I would love to have is something like "M-x dired-do-ispell-comments-and-strings". I am sure there is a simple way to do it, but I don't know how.
A bit rough perhaps, but it seems to work: (add-hook 'dired-load-hook #'(lambda () (defun dired-ispell-comments-and-strings () ;; Return nil for success, else offending file name. (let* ((filename (dired-get-filename)) buffer-read-only failure) (condition-case err (with-current-buffer (find-file filename) (save-excursion (ispell-comments-and-strings))) (error (setq failure err))) (when failure (dired-log "ispell-comments-and-strings error for %s:\n%s\n" filename failure) (dired-make-relative filename)))) (defun dired-do-ispell-comments-and-strings (&optional arg) "`ispell-comments-and-strings' marked (or next ARG) files." (interactive "P") (dired-map-over-marks-check (function dired-ispell-comments-and-strings) arg 'ispell-comments-and-strings t)) (define-key dired-mode-map "c" 'dired-do-ispell-comments-and-strings)))
Matthew Mundell wrote:
A bit rough perhaps, but it seems to work:
(add-hook 'dired-load-hook #'(lambda () (defun dired-ispell-comments-and-strings () ;; Return nil for success, else offending file name. (let* ((filename (dired-get-filename)) buffer-read-only failure) (condition-case err (with-current-buffer (find-file filename) (save-excursion (ispell-comments-and-strings))) (error (setq failure err))) (when failure (dired-log "ispell-comments-and-strings error for %s:\n%s\n" filename failure) (dired-make-relative filename))))
(defun dired-do-ispell-comments-and-strings (&optional arg) "`ispell-comments-and-strings' marked (or next ARG) files." (interactive "P") (dired-map-over-marks-check (function dired-ispell-comments-and-strings) arg 'ispell-comments-and-strings t))
(define-key dired-mode-map "c" 'dired-do-ispell-comments-and-strings)))
Thanks Matthew! I get an error though: dired-do-ispell-comments-and-strings: Symbol's function definition is void: dired-map-over-marks-check Cheers, Roberto -- Prof. Roberto Bagnara Computer Science Group Department of Mathematics, University of Parma, Italy http://www.cs.unipr.it/~bagnara/ mailto:bagnara@cs.unipr.it
I get an error though:
dired-do-ispell-comments-and-strings: Symbol's function definition is void: dired-map-over-marks-check
`dired-map-over-marks-check' is in dired-aux.el, so adding (load "dired-x") or (load "dired-aux") before the function is defined, as below, should sort it out. (add-hook 'dired-load-hook #'(lambda () (load "dired-x") ;; Set dired-x global variables here. For example: ;; (setq dired-guess-shell-gnutar "gtar") ;; (setq dired-x-hands-off-my-keys nil) (defun dired-ispell-comments-and-strings () ;; Return nil for success, else offending file name. (let* ((filename (dired-get-filename)) buffer-read-only failure) (condition-case err (with-current-buffer (find-file filename) (save-excursion (ispell-comments-and-strings))) (error (setq failure err))) (when failure (dired-log "ispell-comments-and-strings error for %s:\n%s\n" filename failure) (dired-make-relative filename)))) (defun dired-do-ispell-comments-and-strings (&optional arg) "`ispell-comments-and-strings' marked (or next ARG) files." (interactive "P") (dired-map-over-marks-check (function dired-ispell-comments-and-strings) arg 'ispell-comments-and-strings t)) (define-key dired-mode-map "c" 'dired-do-ispell-comments-and-strings))
participants (3)
-
Andrea Pescetti -
Matthew Mundell -
Roberto Bagnara