Compare commits

...

2 Commits

1 changed files with 46 additions and 3 deletions

View File

@ -367,6 +367,22 @@ Custom variables used throughout my custom functions/macros.
(defun focks/font-available-p (font-family)
"predicate to check for the existance of the specified font family"
(find-font (font-spec :name font-family)))
(defun focks/compare-lists (l1 l2)
"compare lists L1 and L2.
returns a list containing elements in L1 but not L2 and vice versa"
(cl-flet ((not-in-list (elt lst)
(unless (member elt lst)
elt)))
(list (cl-remove-if-not #'identity
(mapcar #'(lambda (e)
(not-in-list e l2))
l1))
(cl-remove-if-not #'identity
(mapcar #'(lambda (e)
(not-in-list e l1))
l2)))))
#+end_src
@ -487,6 +503,34 @@ Custom variables used throughout my custom functions/macros.
(when (yes-or-no-p "Generate a Makefile and add build instructions for lisp system?")
(asdf-generate-makefile asdf-dir)
(asdf-add-build-instructions asdf-dir)))))
(defun compare-selected-lists (start end)
"pulls two lists from region.
lists should be separated by 2+ newlines
differences are returned in a message to the user."
(interactive (if (use-region-p)
(list (region-beginning) (region-end))
'(nil nil)))
(if (and start end)
(let* ((separator (let ((input (ivy-read "Element separator? " '("newline" ",") :preselect 0)))
(if (equal "newline" input) "\n" input)))
(region (if rectangle-mark-mode
(string-join (mapcar #'string-trim (extract-rectangle start end)) separator)
(buffer-substring start end)))
(list1 (cl-first (string-split region (rx (>= 2 (seq "\n" (0+ whitespace)))) 'omit-nulls)))
(list2 (cl-second (string-split region (rx (>= 2 (seq "\n" (0+ whitespace)))) 'omit-nulls)))
(diffs (focks/compare-lists (string-split list1 separator 'omit-nulls)
(string-split list2 separator 'omit-nulls))))
(message (format (if (cl-some #'identity diffs)
"In first list only: %s\nIn second list only: %s"
"No differences found...")
(string-join (cl-first diffs) ", ")
(string-join (cl-second diffs) ", "))))
(message "No region selected...")))
#+end_src
@ -539,7 +583,7 @@ Custom variables used throughout my custom functions/macros.
** Windows
#+begin_src emacs-lisp
(when-on-windows
(prefer-coding-system 'unix)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'unix)
(set-language-environment "UTF-8")
(set-selection-coding-system 'unix))
@ -554,8 +598,7 @@ Custom variables used throughout my custom functions/macros.
mac-command-modifier 'meta)
;; this used to be in a check for arm64 system arch
;; however, the only systems i personally use that use
;; arm64 are macs, sooooo.
;; however, the only macos systems i use *are* arm64...
(electric-pair-mode 1))
#+end_src