(defvar sacha/project-base-path nil "*The path to the project files, excluding the ending /") (defun sacha/insert-student-files (id) (interactive "MID: ") (if (file-directory-p (concat sacha/project-base-path "/" id)) (progn (cd (concat sacha/project-base-path "/" id)) (mapcar (lambda (item) (print item) (insert "--------------------------------------------------------------------\n") (insert "Your code: " item "\n") (insert "--------------------------------------------------------------------\n") (let ((retval (cadr (insert-file-contents item)))) (goto-char (+ (point) retval)) (insert "\n"))) (file-expand-wildcards "*"))) (insert "***********************************************************\n" "You have not yet submitted any files.\n" "***********************************************************\n"))) (defun sacha/filter-log () "Deletes uninteresting lines from the access log." (interactive) (goto-char (point-min)) (mapcar (lambda (item) (save-excursion (delete-matching-lines item))) "\"-\"" "sacha.free.net.ph" "freshmeat.net" "flyingchair" "richip.dhs.org" "http://www.emacswiki.org/cgi-bin/wiki.*PlannerMode")) (defun sacha/submit-acm-problem () (interactive) (let ((buffer (current-buffer))) (gnus-fetch-group "mail.judge-acm") (gnus-summary-post-news) (save-excursion (when (re-search-forward "--text follows this line--" nil t) (forward-line) (insert-buffer-substring buffer))))) (defun sacha/bbdb-to-foaf (record) "Return the foaf description of RECORD, a BBDB record." (concat "\n" (elt record 0) " " (elt record 1) "\n" (or (mapconcat (lambda (elt) (concat "" (sha1 elt) "\n")) (elt record 6) "") "") (if (bbdb-record-getprop record 'web) (concat "\n") "") (if (bbdb-record-getprop record 'blog) (concat "\n") "") "\n")) (defun sacha/bbdb-to-foaf-to-kill () "Insert a FOAF description into the killring." (interactive) (kill-new (sacha/bbdb-to-foaf (bbdb-current-record)))) (defun sacha/bbdb-insert-as-foaf () "Insert a FOAF description into the current buffer at point." (interactive) (insert (save-excursion (switch-to-buffer bbdb-buffer) (sacha/bbdb-to-foaf (bbdb-current-record))))) (defun sacha/bbdb-find-and-insert-as-foaf (query) "Insert a FOAF description into the current buffer at point." (interactive "MRegexp: ") (insert (sacha/bbdb-to-foaf (car (bbdb-search (bbdb-records) query query query))))) (defun sacha/fix-tla-log () "Correct a wrong commit. Run this inside the arch subdirectory for the patch in your repository, not your project tree." (interactive) ;; Copy the log file (let* ((tar-file (car (file-expand-wildcards "*patches.tar.gz"))) (directory (car (or (file-expand-wildcards "*.patches") (and (call-process "tar" nil nil nil "zxvf" tar-file) (file-expand-wildcards "*.patches"))))) modes (log-file (car (file-expand-wildcards (concat (file-name-as-directory directory) "new-files-archive/{arch}/*/*/*/sacha@free.net.ph--main/patch-log/*")))) log-md5 tar-md5) (when directory (if (file-newer-than-file-p "log" log-file) (progn (delete-file log-file) (copy-file "log" log-file)) (delete-file "log") (copy-file log-file "log")) ;; Recreate the tar.gz (delete-file tar-file) (call-process "tar" nil nil nil "zcvf" tar-file directory) ;; Calculate checksums (with-temp-buffer (call-process "md5sum" nil t nil "log" tar-file) (goto-char (point-min)) (re-search-forward "^\\([^ ]+\\)\\s-+log" nil t) (setq log-md5 (match-string 1)) (re-search-forward "^\\([^ ]+\\)" nil t) (setq tar-md5 (match-string 1))) (with-temp-buffer (setq modes (file-modes "checksum")) (insert-file-contents "checksum") (goto-char (point-min)) (re-search-forward "^Signature-for") (delete-region (point-min) (match-beginning 0)) (re-search-forward "^md5\\s-+log\\s-+\\([^ ]+\\)$") (replace-match log-md5 t t nil 1) (re-search-forward "^md5\\s-+.+?\\.tar\\.gz\\s-+\\([^ ]+\\)$") (replace-match tar-md5 t t nil 1) (when (re-search-forward "BEGIN PGP SIGNATURE" nil t) (delete-region (line-beginning-position) (point-max))) (let ((pgg-output-buffer (current-buffer))) (pgg-sign t)) (delete-file "checksum") ;; Sign the checksum (write-file "checksum") (set-file-modes "checksum" modes))))) (defun sacha/prepare-remarks-file () "Prepare a whatever.txt file containing remarks for the current project." (interactive) (find-file (concat (file-name-nondirectory (directory-file-name default-directory)) ".txt")) (mapcar (lambda (item) (when (file-directory-p item) (goto-char (point-min)) (unless (re-search-forward (concat "^\\*\\s-+" item "\\s-*\n") nil t) (goto-char (point-max)) (insert "\n* " item "\n\n")))) (directory-files default-directory)))