(defvar mk/useful-websites '(("https://regexr.com/" regex debug) ("https://regex101.com/" regex debug) ("https://www.regextester.com/" regex debug) ("https://extendsclass.com/regex-tester.html#python" regex debug) ("https://everything.curl.dev/" curl tool))) (defvar mk/mirror-website "Locally mirror a website using `wget -mkEpnp `") (defvar mk/useful-regex '(("[\w\s]+:" "match any word or space that precede the :") ("\[.*\]" "search for anything in square brackets") ("[A-Za-z]+" "upper and lowercase english alphabet") ("[0-9]" "numbers from 0 to 9") ("[A-Za-z\-\.]" "upper and lowercase english alphabet, - and .") ("(a-z)" "a, - and z") ("(\s+|,)" "spaces or a comma") ("#\w+" "find hashtags") ("([@|#]\w+)" "matches both mentions (@) and hashtags") ("(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)" "email regex") ("-?\d+(\.\d*)?" "matching decimal numbers") ("(?:http|https|ftp|mailto|file|data|irc):\/\/[A-Za-z0-9\-]{0,63}(\.[A-Za-z0-9\-]{0,63})+(:\d{1,4})?\/*(\/*[A-Za-z0-9\-._]+\/*)*(\?.*)?(#.*)?" "matching urls") ("^\d{4}/(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])$" "matching dates yyyy/mm/dd") ("^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/\d{4}$" "matching dates mm/dd/yyyy") ("^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/\d{4}$" "matching dates dd/mm/yyyy") ("<.+>" "matching html") ("<\/?(?:p|a|b|img)(?: \/)?>" "matchig specific tags"))) ;; (defun mk-show-modeline () ;; (interactive) ;; (setq mode-line-format ;; '(("-" mode-line-mule-info ;; mode-line-modified ;; mode-line-frame-identification ;; mode-line-buffer-identification " " ;; mode-line-position ;; mode-line-modes ;; (which-func-mode ;; ("" which-func-format "--")) ;; (global-mode-string ;; ("--" global-mode-string)) "-%-"))) ;; (defvar mode-line-format-current ;; (symbol-value 'mode-line-format))) ;; (defun mk-hide-modeline () ;; (interactive) ;; (setq mode-line-format nil)) ;; (defun mk-write-mode-enable () ;; (setq olivetti-body-width 73) ;; (olivetti-mode) ;; (mk-hide-modeline)) ;; (defun mk-write-mode-disable () ;; (olivetti-mode) ;; (mk-show-modeline)) (defun mk/split-windows-horizontal (count-windows) "Split windows horizontal by equal width." (interactive "nHow many splits? ") (delete-other-windows) (let ((width (/ (window-total-width) count-windows))) (dotimes (i (1- count-windows)) (split-window-right (- width))))) (defun mk/split-windows-vertical (count-windows) "Split windows vertical by equal width." (interactive "nHow many splits? ") (delete-other-windows) (let ((height (/ (window-total-height) count-windows))) (dotimes (i (1- count-windows)) (split-window-below (- height))))) (defun mk/split-h3 () (interactive) (mk/split-windows-horizontal 3)) (defun mk/split-v3 () (interactive) (mk/split-windows-vertical 3)) ;; Set transparency of emacs (defun transparency (value) "Sets the transparency of the frame window. 0=transparent/100=opaque" (interactive "nTransparency Value 0 - 100 opaque: ") (set-frame-parameter (selected-frame) 'alpha value)) (defun mk/show-agenda-list () (if (display-graphic-p) (add-hook 'after-init-hook (lambda () (org-agenda-list) (me/split-h3))) (org-agenda-list))) (defun mk/list-files (folder suffix) (let ((regexp (concat "\\." suffix "$"))) (directory-files folder nil regexp))) (defun mk/build-file-suffix ()) (defun mk/copy-files (src-dir dst-dir suffix) (let ((src-files '()) (src-dir (expand-file-name src-dir)) (dst-dir (expand-file-name dst-dir))) (dolist (file (mk/list-files src-dir suffix) src-files) (let ((src-file (expand-file-name (concat src-dir "/" file))) (dst-file (expand-file-name (concat dst-dir "/" file)))) (add-to-list 'src-files src-file) (copy-file src-file dst-file t))))) (defun mk/delete-files (lst) (dolist (file lst) (delete-file file t))) ;; (defun shr-insert (text) ;; (when (and (not (bolp)) ;; (get-text-property (1- (point)) 'image-url)) ;; (insert "\n")) ;; (cond ;; ((eq shr-folding-mode 'none) ;; (let ((start (point))) ;; (insert text) ;; (save-restriction ;; (narrow-to-region start (point)) ;; (shr--translate-insertion-chars) ;; (goto-char (point-max))))) ;; (t ;; (let ((font-start (point))) ;; (when (and (string-match "\\`[ \t\n\r]" text) ;; (not (bolp)) ;; (not (eq (char-after (1- (point))) ? ))) ;; (insert " ")) ;; (let ((start (point)) ;; (bolp (bolp))) ;; (insert text) ;; (save-restriction ;; (narrow-to-region start (point)) ;; (goto-char start) ;; (when (looking-at "[\t\n\r]+") ;; (replace-match "" t t)) ;; (while (re-search-forward "[\t\n\r]+" nil t) ;; (replace-match " " t t)) ;; (goto-char start) ;; (while (re-search-forward " +" nil t) ;; (replace-match " " t t)) ;; (shr--translate-insertion-chars) ;; (goto-char (point-max))) ;; ;; We may have removed everything we inserted if it was just ;; ;; spaces. ;; (unless (= font-start (point)) ;; ;; Mark all lines that should possibly be folded afterwards. ;; (when bolp ;; (shr-mark-fill start)) ;; (when shr-use-fonts ;; (put-text-property font-start (point) ;; 'face ;; (or shr-current-font 'variable-pitch)))))))))