;; Emacs-Time-stamp: "2007-09-27 18:00:40" (setq file-stamp "Emacs-File-stamp: \"/home/ysverdlov/leninist.biz/lb-misc.el\"") ;; (lb-delete-files "~/leninist.biz/en/1989/HCM243/" "HTML document text") (defun lb-delete-files (arg1path arg2file-filetype) "" ;; (let (lb-filelist lb-filetype _rc) (save-match-data (loop for file in (directory-files arg1path t) do (if (and ;; OPTIONAL: (not (string-match "[.]jp[e]?g$" file)) ;; MANDATORY: (string= arg2file-filetype (_-filetype file))) (setq lb-filelist (append lb-filelist (list file))))) (loop for file in lb-filelist do (delete-file file))) _rc)) (defun tab-renumber-col- (&optional arg1col) " Start with point on last line with correct number" ;; ;; hrefs 16 4-I . z ;; hrefs 17 4-1 . z ;; hrefs 17 4-2 . z ;; hrefs 18 4-3 . z (interactive) ;; fix! ;; Leave trailing hypen alone if "[introduction.]" in description. ;; fix! Re-use code that checks for .ABC at end of filename. (let (_re-col _n _line _col _pt-dash-tab _trailing-pounds _flag-roman-numerals-after-trailing-dash _col-roman-numerals-after-trailing-dash (_cnt-roman-numerals-after-trailing-dash -1) _rc) (save-excursion ;; 2007.03.28 (goto-char (point-min)) (tx-move-forward-past-pound-comment-lines) (beginning-of-line) (if (not arg1col) (setq arg1col (string-to-int (read-input "Col? ")))) (setq _re-col "^[^\t]+") (loop for i from (1+ (- arg1col (1- arg1col))) to arg1col do (setq _re-col (concat _re-col "\t" "\\([^\t]*\\)"))) (beginning-of-line) (while (and (search-forward-regexp _re-col nil t) (setq _msnp1 (match-string-no-properties 1)) ;; Ignore "#" at end of string in target column. (save-match-data (setq _trailing-pounds (if (string-match ;; 2006.12.04 - Keep letter-for-sorting. ;; "[#]+$" "[a-z]?[#]+$" _msnp1) (match-string-no-properties 0 _msnp1) "")) t) (progn (replace-match (concat (format "%02d" (setq _n (+ (if (string= "" _trailing-pounds) 1 0) (if (not _n) (setq _n (1- (string-to-int _msnp1)) ) _n) ))) _trailing-pounds) t t nil 1) t) ) ;; and ;; fix! ;; "ABC-" has to be done manually; after that, ;; skip if only one instance; it means "introduction": ;;; hrefs 40 CAK- . z ;;; hrefs 41 CAK-I . z ;; fix! ;; Does not detect change of root name when two blocks are ;; next to one another; e.g., below no "QIRH-I" ;;; hrefs 18 EF- . [ON THE ``ECONOMIC FACTOR'' ... ;;; hrefs 18 EF- . [ON THE ``ECONOMIC FACTOR'' ... ;;; hrefs 19 QIRH- . ON THE QUESTION OF THE INDIVIDUAL'S ... ;;; hrefs 19 QIRH- . ON THE QUESTION OF THE INDIVIDUAL'S ... (if ;; Try to append Roman numerals after a trailing dash. (or ;; 2006.10.04 - Allow "ABC-" to mean introduction. (string-match "[[]introduction[.]?[]]" (setq _line (_-current-line))) (string-match "INTRODUCTION$" (setq _line (_-current-line))) (not (string-match "[a-z0-9A-Z][-][\t]" _line) )) ;; RESET. (progn (setq _col-roman-numerals-after-trailing-dash (setq _flag-roman-numerals-after-trailing-dash nil)) (setq _cnt-roman-numerals-after-trailing-dash -1)) ;; Where was that? (setq _pt-dash-tab (+ (save-excursion (beginning-of-line) (point)) (match-end 0))) ;; Was question asked for this group before? (if (not _flag-roman-numerals-after-trailing-dash) (while (not (setq _flag-roman-numerals-after-trailing-dash ;; fix! change this to the read that just needs 'y' w/o ENTER. (read-input (concat (substring _line 0 (match-end 0)) "ROMAN NUMERALS? " )))))) ;; Count tabs to left. (if (and (setq _col (1- (length (split-string (substring _line 0 (match-end 0)) "[\t]")))) _col-roman-numerals-after-trailing-dash (/= _col _col-roman-numerals-after-trailing-dash)) (error "%s: %s" "oh" "no") (setq _col-roman-numerals-after-trailing-dash _col)) ;; Add Roman numeral. (when (string-match "[^nN]*[yY]" _flag-roman-numerals-after-trailing-dash) (setq _cnt-roman-numerals-after-trailing-dash (1+ _cnt-roman-numerals-after-trailing-dash)) (goto-char (1- _pt-dash-tab)) (insert (nth _cnt-roman-numerals-after-trailing-dash lb-list-roman-numerals))) ) ;; if has dash-tab ) ;; while ) ;; save-excursion (occur "[.]...[\t]") _rc)) ;; (defun lb-wdiff (arg1pfnew arg2action) "ARG1 is disk-file in the process of creation. If nil, defaults to lbg-wdiff-pf. ARG2 is 'beg' (before disk-write) or 'end' (after disk-write)" ;; (let (_list _pf (_ext ".wdiffin") _rc) (if arg1pfnew (setq lbg-wdiff-pf arg1pfnew) (setq arg1pfnew lbg-wdiff-pf)) (setq _pf (concat arg1pfnew _ext)) (cond ((string= "beg" arg2action) (if (file-exists-p _pf) (delete-file _pf)) (if (file-exists-p arg1pfnew) (copy-file arg1pfnew _pf))) ((string= "end" arg2action) (if (not (file-exists-p _pf)) (setq _list (list "a" "b" "c")) ;; (with-temp-buffer ;; wdiff ignores changes to whitespace. (shell-command (concat "wdiff " _pf " " arg1pfnew) t) (goto-char (point-min)) (while (search-forward-string "[-" nil t) (setq _list (append _list (list (_-current-line)))) (search-forward-string "-]")) (goto-char (point-min)) (while (search-forward-string "{+" nil t) (setq _list (append _list (list (_-current-line)))) (search-forward-string "+}")) )) ;; ;; Check. (if (not _list) (error "%s: %s" "Why no differences, not even time-stamps?" _pf)) ;; (if (or (> (length _list) 1) (not (string-match "Emacs-Time-stamp:" (car _list)))) (lb-lftp-dosomething-file arg1pfnew)) ;; (if (file-exists-p _pf) (delete-file _pf))) ;; --------------------------------- (t (error "%s: %s" "Programming" "error"))) _rc)) (provide 'lb-misc) ;;; ;