Skip to content

Commit fdaaffa

Browse files
committed
comment out all the icons stuff that builds good looking dired icons
1 parent 00f17ac commit fdaaffa

File tree

1 file changed

+118
-116
lines changed

1 file changed

+118
-116
lines changed

functions.el

+118-116
Original file line numberDiff line numberDiff line change
@@ -969,122 +969,124 @@
969969
;; (run-at-time "04:05:00" (* 1440 60) 'jj/org-gcal-fetch-when-idle-full)
970970
;; ))
971971
)
972-
(use-package all-the-icons
973-
:config
974-
(defvar all-the-icons--size-data
975-
(make-hash-table :test #'equal)
976-
"Icon size data (WIDTH . HEIGHT). Keys formatted as (FAMILY . ICON-NAME)")
977-
978-
(defun segment-pixel-width (start end)
979-
"Calculate and return the width (in pixels) of the segment between START and END."
980-
(save-current-buffer
981-
(save-excursion
982-
(when (markerp start)
983-
(switch-to-buffer (marker-buffer start))
984-
(set-buffer (marker-buffer start)))
985-
(-let* ((start-x (window-x-pixel-position start))
986-
(end-x (window-x-pixel-position end)))
987-
(when (and start-x end-x)
988-
(- end-x start-x))))))
989-
990-
(defun segment-pixel-height (start end)
991-
"Calculate and return the height (in pixels) of the segment between START and END."
992-
(save-current-buffer
993-
(save-excursion
994-
(when (markerp start)
995-
(switch-to-buffer (marker-buffer start))
996-
(set-buffer (marker-buffer start)))
997-
(-let* ((start-y (window-y-pixel-position start))
998-
(end-y (window-y-pixel-position end)))
999-
(when (and start-y end-y)
1000-
(- end-y start-y))))))
1001-
1002-
(defun window-x-pixel-position (pos)
1003-
(car (progn (goto-char pos)
1004-
(or (window-absolute-pixel-position pos)
1005-
(progn (redisplay)
1006-
(window-absolute-pixel-position pos))))))
1007-
1008-
(defun window-y-pixel-position (pos)
1009-
(cdr (progn (goto-char pos)
1010-
(or (window-absolute-pixel-position pos)
1011-
(progn (redisplay)
1012-
(window-absolute-pixel-position pos))))))
1013-
1014-
(defun build-icon-dimension-data ()
1015-
"Build a database of rendered icon dimensions."
1016-
(interactive)
1017-
(save-current-buffer
1018-
(let ((buffer (get-buffer-create "*icon-indexing*")))
1019-
(switch-to-buffer buffer)
1020-
(delete-region (point-min) (point-max))
1021-
(let ((line-height (line-pixel-height)) ; 15
1022-
(char-width (progn (insert " ") (segment-pixel-width (point-min) (point-max))))) ; 7
1023-
(mapc
1024-
(lambda (family)
1025-
(let ((family-name (funcall (all-the-icons--family-name family)))
1026-
(data-alist (funcall (all-the-icons--data-name family))))
1027-
(mapcar
1028-
(-lambda ((name . icon))
1029-
(delete-region (point-min) (point-max))
1030-
(insert (propertize icon 'font-lock-ignore t 'face `(:family ,family-name :height 4.0)))
1031-
(redisplay)
1032-
(puthash (cons family name)
1033-
(cons (/ (segment-pixel-width (point-min) (point-max)) (* char-width 4.0))
1034-
(/ (line-pixel-height) (* line-height 4.0)))
1035-
all-the-icons--size-data))
1036-
data-alist)))
1037-
all-the-icons-font-families))
1038-
(kill-buffer buffer))))
1039-
1040-
(defalias 'jj/build-all-the-icon-dimension-data 'build-icon-dimension-data)
1041-
1042-
(defmacro define-icon (name alist family &optional font-name)
1043-
"Macro to generate functions for inserting icons for icon set NAME.
1044-
1045-
NAME defines is the name of the iconset and will produce a
1046-
function of the for `all-the-icons-NAME'.
1047-
1048-
ALIST is the alist containing maps between icon names and the
1049-
UniCode for the character. All of these can be found in the data
1050-
directory of this package.
1051-
1052-
FAMILY is the font family to use for the icons.
1053-
FONT-NAME is the name of the .ttf file providing the font, defaults to FAMILY."
1054-
`(progn
1055-
(add-to-list 'all-the-icons-font-families (quote ,name))
1056-
(add-to-list 'all-the-icons-font-names (quote ,(downcase (format "%s.ttf" (or font-name family)))))
1057-
(defun ,(all-the-icons--family-name name) () ,family)
1058-
(defun ,(all-the-icons--data-name name) () ,alist)
1059-
(defun ,(all-the-icons--function-name name) (icon-name &rest args)
1060-
(let* ((icon (cdr (assoc icon-name ,alist)))
1061-
(other-face (when all-the-icons-color-icons (plist-get args :face)))
1062-
(scale (car (gethash (cons ',name icon-name) all-the-icons--size-data)))
1063-
(height (/ (if (> scale 1.2) 2 1) scale))
1064-
(v-adjust (/ (* (if (> scale 1.2) 2 1) (or (plist-get args :v-adjust) all-the-icons-default-adjust)) scale))
1065-
(family ,family))
1066-
(unless icon
1067-
(error (format "Unable to find icon with name `%s' in icon set `%s'" icon-name (quote ,name))))
1068-
(let ((face (if other-face
1069-
`(:family ,family :height ,height :inherit ,other-face)
1070-
`(:family ,family :height ,height))))
1071-
(propertize icon
1072-
'face face ;so that this works without `font-lock-mode' enabled
1073-
'font-lock-face face ;so that `font-lock-mode' leaves this alone
1074-
'display `(raise ,v-adjust)
1075-
'rear-nonsticky t))))
1076-
(defun ,(all-the-icons--insert-function-name name) (&optional arg)
1077-
,(format "Insert a %s icon at point." family)
1078-
(interactive "P")
1079-
(all-the-icons-insert arg (quote ,name)))))
1080-
1081-
(define-icon alltheicon all-the-icons-data/alltheicons-alist "all-the-icons")
1082-
(define-icon fileicon all-the-icons-data/file-icon-alist "file-icons")
1083-
(define-icon faicon all-the-icons-data/fa-icon-alist "FontAwesome")
1084-
(define-icon octicon all-the-icons-data/octicons-alist "github-octicons" "octicons")
1085-
(define-icon wicon all-the-icons-data/weather-icons-alist "Weather Icons" "weathericons")
1086-
(define-icon material all-the-icons-data/material-icons-alist "Material Icons" "material-design-icons")
1087-
)
972+
(use-package all-the-icons)
973+
;; TODO: some issue with the following code when moving macs that needs fixed
974+
;; (use-package all-the-icons
975+
;; :config
976+
;; (defvar all-the-icons--size-data
977+
;; (make-hash-table :test #'equal)
978+
;; "Icon size data (WIDTH . HEIGHT). Keys formatted as (FAMILY . ICON-NAME)")
979+
980+
;; (defun segment-pixel-width (start end)
981+
;; "Calculate and return the width (in pixels) of the segment between START and END."
982+
;; (save-current-buffer
983+
;; (save-excursion
984+
;; (when (markerp start)
985+
;; (switch-to-buffer (marker-buffer start))
986+
;; (set-buffer (marker-buffer start)))
987+
;; (-let* ((start-x (window-x-pixel-position start))
988+
;; (end-x (window-x-pixel-position end)))
989+
;; (when (and start-x end-x)
990+
;; (- end-x start-x))))))
991+
992+
;; (defun segment-pixel-height (start end)
993+
;; "Calculate and return the height (in pixels) of the segment between START and END."
994+
;; (save-current-buffer
995+
;; (save-excursion
996+
;; (when (markerp start)
997+
;; (switch-to-buffer (marker-buffer start))
998+
;; (set-buffer (marker-buffer start)))
999+
;; (-let* ((start-y (window-y-pixel-position start))
1000+
;; (end-y (window-y-pixel-position end)))
1001+
;; (when (and start-y end-y)
1002+
;; (- end-y start-y))))))
1003+
1004+
;; (defun window-x-pixel-position (pos)
1005+
;; (car (progn (goto-char pos)
1006+
;; (or (window-absolute-pixel-position pos)
1007+
;; (progn (redisplay)
1008+
;; (window-absolute-pixel-position pos))))))
1009+
1010+
;; (defun window-y-pixel-position (pos)
1011+
;; (cdr (progn (goto-char pos)
1012+
;; (or (window-absolute-pixel-position pos)
1013+
;; (progn (redisplay)
1014+
;; (window-absolute-pixel-position pos))))))
1015+
1016+
;; (defun build-icon-dimension-data ()
1017+
;; "Build a database of rendered icon dimensions."
1018+
;; (interactive)
1019+
;; (save-current-buffer
1020+
;; (let ((buffer (get-buffer-create "*icon-indexing*")))
1021+
;; (switch-to-buffer buffer)
1022+
;; (delete-region (point-min) (point-max))
1023+
;; (let ((line-height (line-pixel-height)) ; 15
1024+
;; (char-width (progn (insert " ") (segment-pixel-width (point-min) (point-max))))) ; 7
1025+
;; (mapc
1026+
;; (lambda (family)
1027+
;; (let ((family-name (funcall (all-the-icons--family-name family)))
1028+
;; (data-alist (funcall (all-the-icons--data-name family))))
1029+
;; (mapcar
1030+
;; (-lambda ((name . icon))
1031+
;; (delete-region (point-min) (point-max))
1032+
;; (insert (propertize icon 'font-lock-ignore t 'face `(:family ,family-name :height 4.0)))
1033+
;; (redisplay)
1034+
;; (puthash (cons family name)
1035+
;; (cons (/ (segment-pixel-width (point-min) (point-max)) (* char-width 4.0))
1036+
;; (/ (line-pixel-height) (* line-height 4.0)))
1037+
;; all-the-icons--size-data))
1038+
;; data-alist)))
1039+
;; all-the-icons-font-families))
1040+
;; (kill-buffer buffer))))
1041+
1042+
;; (defalias 'jj/build-all-the-icon-dimension-data 'build-icon-dimension-data)
1043+
1044+
;; (defmacro define-icon (name alist family &optional font-name)
1045+
;; "Macro to generate functions for inserting icons for icon set NAME.
1046+
1047+
;; NAME defines is the name of the iconset and will produce a
1048+
;; function of the for `all-the-icons-NAME'.
1049+
1050+
;; ALIST is the alist containing maps between icon names and the
1051+
;; UniCode for the character. All of these can be found in the data
1052+
;; directory of this package.
1053+
1054+
;; FAMILY is the font family to use for the icons.
1055+
;; FONT-NAME is the name of the .ttf file providing the font, defaults to FAMILY."
1056+
;; `(progn
1057+
;; (add-to-list 'all-the-icons-font-families (quote ,name))
1058+
;; (add-to-list 'all-the-icons-font-names (quote ,(downcase (format "%s.ttf" (or font-name family)))))
1059+
;; (defun ,(all-the-icons--family-name name) () ,family)
1060+
;; (defun ,(all-the-icons--data-name name) () ,alist)
1061+
;; (defun ,(all-the-icons--function-name name) (icon-name &rest args)
1062+
;; (let* ((icon (cdr (assoc icon-name ,alist)))
1063+
;; (other-face (when all-the-icons-color-icons (plist-get args :face)))
1064+
;; (scale (car (gethash (cons ',name icon-name) all-the-icons--size-data)))
1065+
;; (height (/ (if (> scale 1.2) 2 1) scale))
1066+
;; (v-adjust (/ (* (if (> scale 1.2) 2 1) (or (plist-get args :v-adjust) all-the-icons-default-adjust)) scale))
1067+
;; (family ,family))
1068+
;; (unless icon
1069+
;; (error (format "Unable to find icon with name `%s' in icon set `%s'" icon-name (quote ,name))))
1070+
;; (let ((face (if other-face
1071+
;; `(:family ,family :height ,height :inherit ,other-face)
1072+
;; `(:family ,family :height ,height))))
1073+
;; (propertize icon
1074+
;; 'face face ;so that this works without `font-lock-mode' enabled
1075+
;; 'font-lock-face face ;so that `font-lock-mode' leaves this alone
1076+
;; 'display `(raise ,v-adjust)
1077+
;; 'rear-nonsticky t))))
1078+
;; (defun ,(all-the-icons--insert-function-name name) (&optional arg)
1079+
;; ,(format "Insert a %s icon at point." family)
1080+
;; (interactive "P")
1081+
;; (all-the-icons-insert arg (quote ,name)))))
1082+
1083+
;; (define-icon alltheicon all-the-icons-data/alltheicons-alist "all-the-icons")
1084+
;; (define-icon fileicon all-the-icons-data/file-icon-alist "file-icons")
1085+
;; (define-icon faicon all-the-icons-data/fa-icon-alist "FontAwesome")
1086+
;; (define-icon octicon all-the-icons-data/octicons-alist "github-octicons" "octicons")
1087+
;; (define-icon wicon all-the-icons-data/weather-icons-alist "Weather Icons" "weathericons")
1088+
;; (define-icon material all-the-icons-data/material-icons-alist "Material Icons" "material-design-icons")
1089+
;; )
10881090

10891091
(use-package all-the-icons-dired
10901092
:diminish all-the-icons-dired-mode

0 commit comments

Comments
 (0)