Last active
December 10, 2015 08:48
-
-
Save Longlius/4410346 to your computer and use it in GitHub Desktop.
Example emacs lisp program to generate programmer activity reports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Script Name: epractivity.el | |
;;;; By: MWL | |
;;;; Date: 07 October 2012 | |
;;;; Purpose: Generate Programmer Activity Status Report using emacs | |
;; Open the file 'programmer' into a buffer. | |
;; Set that buffer as the current buffer. | |
(set-buffer (find-file "programmer")) | |
;; Convert the buffer into a string, then split that string | |
;; into a list containing each line as a separate string | |
(setq programmer_lines (split-string (buffer-string) | |
"\n")) | |
;; Kill the buffer containing 'programmer' | |
(kill-buffer) | |
;; Repeat for file 'project' | |
(set-buffer (find-file "project")) | |
(setq project_lines (split-string (buffer-string) | |
"\n")) | |
(kill-buffer) | |
;; Make a vector of names by programmer number | |
(setq prog_number | |
(let* ((plen (length programmer_lines)) | |
(pnum (make-vector plen ""))) | |
(dolist (currprog programmer_lines pnum) | |
(let* ((pfields (split-string currprog ":")) | |
(ind (- (string-to-number (nth 0 pfields)) 101)) | |
(val (format "%-12.12s %-12.12s %s" | |
(nth 1 pfields) | |
(nth 2 pfields) | |
(nth 3 pfields)))) | |
(unless (or (< ind 0) (> ind plen)) | |
(aset pnum ind val)))))) | |
;; Make a vector of the number of projects by programmer number | |
(setq proj_number | |
(let* ((plen (length prog_number)) | |
(pnum (make-vector plen 0))) | |
(dolist (currproj project_lines pnum) | |
(let* ((pfields (split-string currproj ":")) | |
(ind (- (string-to-number (nth 3 pfields)) 101))) | |
(unless (or (< ind 0) (> ind plen)) | |
(aset pnum ind (1+ (aref pnum ind)))))))) | |
;; Finally, print the output | |
(princ "\tProgrammer Activity Status Report\n\n") | |
(princ (format-time-string "\t%a %b %d %H:%M:%S %Z %Y\n")) | |
(princ "Prog#\t*--Name--*\t\t\tProjects\n\n") | |
(princ "================================================\n") | |
(dotimes (ind (length prog_number)) | |
(princ (format "%-d\t%s\t%d\n" | |
(+ ind 101) | |
(aref prog_number ind) | |
(aref proj_number ind)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment