From 7827e93cd050e0e2ef029ccc460ceb567aa25937 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 4 Aug 2020 19:46:54 +0100 Subject: jao-sloc moved --- misc/jao-sloc.el | 32 -------------------------------- prog/jao-sloc.el | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 misc/jao-sloc.el create mode 100644 prog/jao-sloc.el diff --git a/misc/jao-sloc.el b/misc/jao-sloc.el deleted file mode 100644 index 9e38017..0000000 --- a/misc/jao-sloc.el +++ /dev/null @@ -1,32 +0,0 @@ -;; sloc.el -- LOC utilities - -(defun count-sloc-region (beg end kind) - "Count source lines of code in region (or (narrowed part of) - the buffer when no region is active). SLOC means that empty - lines and comment-only lines are not taken into consideration. - - (function by Stefan Monnier). - " - (interactive - (if (use-region-p) - (list (region-beginning) (region-end) 'region) - (list (point-min) (point-max) 'buffer))) - (save-excursion - (goto-char beg) - (let ((count 0)) - (while (< (point) end) - (cond - ((nth 4 (syntax-ppss)) ;; BOL is already inside a comment. - (let ((pos (point))) - (goto-char (nth 8 (syntax-ppss))) - (forward-comment (point-max)) - (if (< (point) pos) (goto-char pos)))) ;; Just paranoia - (t (forward-comment (point-max)))) - (setq count (1+ count)) - (forward-line)) - (when kind - (message "SLOC in %s: %s." kind count))))) - - -(provide 'jao-sloc) -;;; sloc.el ends here diff --git a/prog/jao-sloc.el b/prog/jao-sloc.el new file mode 100644 index 0000000..1f0e9ab --- /dev/null +++ b/prog/jao-sloc.el @@ -0,0 +1,33 @@ +;; sloc.el -- LOC utilities + +;;;###autoload +(defun count-sloc-region (beg end kind) + "Count source lines of code in region (or (narrowed part of) + the buffer when no region is active). SLOC means that empty + lines and comment-only lines are not taken into consideration. + + (function by Stefan Monnier). + " + (interactive + (if (use-region-p) + (list (region-beginning) (region-end) 'region) + (list (point-min) (point-max) 'buffer))) + (save-excursion + (goto-char beg) + (let ((count 0)) + (while (< (point) end) + (cond + ((nth 4 (syntax-ppss)) ;; BOL is already inside a comment. + (let ((pos (point))) + (goto-char (nth 8 (syntax-ppss))) + (forward-comment (point-max)) + (if (< (point) pos) (goto-char pos)))) ;; Just paranoia + (t (forward-comment (point-max)))) + (setq count (1+ count)) + (forward-line)) + (when kind + (message "SLOC in %s: %s." kind count))))) + + +(provide 'jao-sloc) +;;; sloc.el ends here -- cgit v1.2.3