+;; -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Ian Kelling
;; This program is free software: you can redistribute it and/or modify
-;; stop from minimizing & freezing the gui
-;; used to freeze emacs and was really annoying,
-;; seems its changed now. no harm in keeping this though.
+;; Used to freeze the gui, which it doesn't anymore, but still good to
+;; unbind it since we bind it later, in the case that our init.el gets
+;; only partially executed.
(global-unset-key (kbd "C-z"))
;; emacs holds open files in the eln-cache, preventing umount, so move
;; ; emacs -f benchmark-init/deactivate
-(setq init-dir (file-name-directory load-file-name))
-
;; these need to be done before the hook in order to satisfy the byte compiler or batch mode
(add-to-list 'load-path (concat user-emacs-directory "src/readline-complete"))
;; I'm gonna delete the cache, and check on it later see what exactly is going in there
;; And of course, I moved ~/News to my encrypted drive and symlinked it
-
-
;;; things that should be at the beginning
-;; from its README.md
-(eval-when-compile
- (require 'use-package))
-(use-package use-package-ensure-system-package
- :ensure t)
-
;; Ubiquitous Packages. these could go anywhere actually
;; find file at point
;;(require 'src-loaddefs)
+(setenv "EMACS" "")
;; generally unnecessary, but why not
-(setq explicit-shell-file-name "bash")
+(setq explicit-shell-file-name "bash"
+ explicit-bash-args nil
+ comint-process-echoes t)
;; readline-complete says to add this line.
;; however, it up my procfs directory tracking hook
;; and done stty echo in my bashrc
;;(setq explicit-bash-args '("-c" "export EMACS=; stty echo; bash"))
-(setenv "EMACS" "")
-(setq explicit-bash-args nil)
-(setq comint-process-echoes t)
;; todo: consider if this is needed in company mode.
;;(define-key keymap "\C-\M-s" 'company-filter-candidates)
(define-key company-active-map "\C-\M-s" nil)
+ ;; taken from readline-complete.el . to fully switch over to company mode, uncomment these
+ ;;(push 'company-readline company-backends)
+ ;;(add-hook 'rlc-no-readline-hook (lambda () (company-mode -1)))
)
(add-hook 'after-init-hook 'my-company-config)
(use-package recentf
;; defer & commands from jwiegley
- :defer 10
+ :defer 5
:if (string= (daemonp) "server")
:commands (recentf-mode
recentf-add-file
savehist-file (concat user-emacs-directory ".savehist"))
(savehist-mode 1))
+;;; vertico
+(setq read-file-name-completion-ignore-case t
+ read-buffer-completion-ignore-case t
+ completion-ignore-case t)
+
+;; Enable Vertico.
+(use-package vertico
+ :custom
+ ;; (vertico-scroll-margin 0) ;; Different scroll margin
+ (vertico-count 20) ;; Show more candidates
+ ;;(vertico-resize t) ;; Grow and shrink the Vertico minibuffer
+ (vertico-cycle t) ;; Enable cycling for `vertico-next/previous'
+ (keymap-set vertico-map "TAB" #'minibuffer-complete)
+ :init
+ (vertico-mode))
+
+;; Emacs minibuffer configurations.
+(use-package emacs
+ :custom
+ ;; Support opening new minibuffers from inside existing minibuffers.
+ (enable-recursive-minibuffers t)
+ ;; Hide commands in M-x which do not work in the current mode. Vertico
+ ;; commands are hidden in normal buffers. This setting is useful beyond
+ ;; Vertico.
+ (read-extended-command-predicate #'command-completion-default-include-p)
+ ;; Do not allow the cursor in the minibuffer prompt
+ (minibuffer-prompt-properties
+ '(read-only t cursor-intangible t face minibuffer-prompt)))
+
+(use-package orderless
+ :custom
+ ;; Configure a custom style dispatcher (see the Consult wiki)
+ ;; (orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch))
+ ;; (orderless-component-separator #'orderless-escapable-split-on-space)
+ (completion-styles '(orderless basic))
+ (completion-category-defaults nil)
+ (completion-category-overrides '((file (styles partial-completion)))))
+
;;; image dired
-;; dont see how to make this change existing thumbs
-;; image-dired-thumb-size
+(setq image-dired-debug t
+ image-dired-marking-shows-next nil
+ ;; just testing it out in case
+ image-dired-track-movement nil
+ image-dired-thumb-margin 1
+ ;; odd useless borders
+ image-dired-thumb-relief 0
+ image-auto-resize 'fit-window
+ image-dired-thumb-size 400
+ ;; image-dired-cmd-create-temp-image-options ("convert" "-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t" "-filter" "Lanczos" "-colorspace" "RGB" "-define" "jpeg:dct-method=float" "-quality" "95")
+ ;;image-dired-cmd-create-thumbnail-options ("convert" "-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t" "-filter" "Lanczos" "-colorspace" "RGB" "-define" "jpeg:dct-method=float" "-quality" "95")
+ image-dired-cmd-create-thumbnail-options '("convert" "%f" "-strip" "-resize" "%wx%h" "-filter" "Lanczos" "-define" "jpeg:dct-method=float" "-quality" "95" "%t")
+ image-dired-cmd-create-thumbnail-options '("true")
+ )
+
+
+(defun imgdired-rating ()
+ "highlight"
+ (interactive)
+ (with-current-buffer image-dired-thumbnail-buffer
+ (save-mark-and-excursion
+ (goto-char (point-min))
+ (let ((inhibit-read-only t))
+ (while (not (eobp))
+ (when-let* ((file-path (image-dired-original-file-name))
+ (file (file-name-nondirectory file-path)))
+ (image-dired-rating-highlight-at-point file))
+ (forward-char 2))))))
+
+;; find new faces with (list-faces-display)
+(defun image-dired-rating-highlight-at-point (file)
+ (with-silent-modifications
+ (let* ((rating (gethash file khash)))
+ (cond ((and rating (>= rating 4))
+ (add-face-text-property (point) (1+ (point))
+ 'shr-mark))
+ ((and rating (= rating 3))
+ (add-face-text-property (point) (1+ (point))
+ 'reb-match-1))
+ ((and rating (= rating 1))
+ ;; brown
+ (add-face-text-property (point) (1+ (point))
+ 'reb-match-3))
+ (t (remove-text-properties (point) (1+ (point))
+ '(face reb-match-1)))))))
+
+;; successfull font markup test:
+;; (with-silent-modifications (add-face-text-property (point) (+ 10 (point)) 'image-dired-thumb-mark))
+;; ;; [45] bright yellow: shr-mark
+;; ;; [3] medium blue: reb-match-1
+;; ;; [12] light brown
+;;
+
+;; scratch pad for looking over the thumb width calculations:
+;; char-width: (frame-char-width) = 9
+;; width: (window-body-width (image-dired-thumbnail-window) t) = 2777
+
+
+;; The same-window helps prevent image-dired window from jumping all around, but it doesn't completely stop it.
+
+;; (setq display-buffer-alist '((".*" display-buffer-reuse-window)))
+;; (setq display-buffer-alist '((".*" display-buffer-in-previous-window)))
+;; (setq display-buffer-alist '((".*" display-buffer-same-window)))
+;; (setq display-buffer-alist nil)
+;; (setq image-dired-track-movement nil)
+;; (setq image-dired-track-movement t)
+;;
+;; I eventually solved it based on a patch in debbugs waiting for review.
+
+
;;; dired
;; dired - reuse current buffer by pressing 'a'
-(put 'dired-find-alternate-file 'disabled nil)
+;;(put 'dired-find-alternate-file 'disabled nil)
;; copied from dired-x info manual
(temp-buffer-resize-mode 1)
-(defun my-info-init()
- (require 'info+)
- ;; based on suggestions in info+.el, I also installed misc-fns, strings, and thingatpt+
- ;; remove some bad keybinds from info+
- (define-key Info-mode-map [mouse-4] nil)
- (define-key Info-mode-map [mouse-5] nil))
-
-(add-hook 'info-mode-hook 'my-info-init)
;;; misc general settings
-(ivy-mode 1)
(add-hook 'text-mode-hook (lambda () (auto-fill-mode t)))
-(setq counsel-find-file-at-point t)
(eval-after-load "ido"
;; easier to read with just spaces as separator
;;; prog-mode-defaults
+(defface highlight-symbol-face
+ '((((class color) (background dark))
+ (:background "gray30"))
+ (((class color) (background light))
+ (:background "gray90")))
+ "highlight-symbol-face copied from `highlight-symbol-mode' for use in maintained replacement mode: highlight-thing-mode.")
+
(defun prog-mode-defaults ()
"Default coding hook, useful with any programming language."
;; todo, this is causing error message on loading file, prolly not working
;;(flycheck-mode +1)
- (highlight-symbol-mode)
+ (idle-highlight-mode)
+ (setq idle-highlight-idle-time 0.1)
+
+
+
(make-local-variable 'column-number-mode)
;; this says do autofilling using newcomment.el. The "only" is a misnomer.
(set (make-local-variable 'comment-auto-fill-only-comments) t)
ispell-program-name "hunspell"
ispell-silently-savep t) ; don't prompt to save personal dictionary
-(use-package rw-hunspell
- :defer t)
-;; rw-hunspell sets up hunspell dictionary automagically.
-
(use-package flyspell
- :ensure-system-package hunspell
:hook ((prog-mode . flyspell-prog-mode)
(text-mode . turn-on-flyspell)))
(setq dir parent-dir
parent-dir (file-name-directory (directory-file-name parent-dir))))
nearest-compilation-file))
+
(defun run ()
(interactive)
"call run-fun if it is set, else run make if there is a makefile,
(switch-to-buffer original-buffer)
(setq buffer (get-buffer buffer-name)))
(error "No existing buffer found and no init function argument. ")))
- (buffer-window-show buffer)
+ (iank-buffer-window-show buffer)
(with-current-buffer buffer
(let ((proc (get-buffer-process buffer)))
(goto-char (process-mark proc))
(insert string)
(comint-send-input nil t)))))
-(defun buffer-window-show (&optional buffer action)
+(defun iank-buffer-window-show (&optional buffer action)
"Like temp-buffer-window-show, but removed stuff
relevant to it being temp or help."
(let (window frame)
;; but those things are often nil.
;; aha moments in reading it: ACTION = (FUNCTION-or-FUNCTIONLIST ALIST)
;; FRAME adds an association to ACTION's alist, but it's not used if ACTION arg is nil.
+;;
(setq display-buffer-fallback-action `(,(car display-buffer-fallback-action) . '(reusable-frames . visible)))
+
;; stop splitting windows verticallly when I open a buffer or shell
(setq split-height-threshold nil)
+;; 2025: trying this out just to experiment.
+(setq split-width-threshold nil)
;;;;; s-left arrow - ---
;; cant be used in terminal
(global-set-key (kbd "C-M-q") 'quoted-insert)
-;;;;; C-w counsel-find-file
+;;;;; C-w find-file
-(global-set-key (kbd "C-w") 'counsel-find-file)
+(global-set-key (kbd "C-w") 'ffap)
+;; old, just fyi
+;;(global-set-key (kbd "C-w") 'counsel-find-file)
;;;;; M-w shell
(global-set-key (kbd "C-M-g") 'mu4e)
-;;;;; C-z - undo-only
+;;;;; C-z - undo
;;(global-set-key (kbd "C-z") 'undo-tree-undo)
(global-set-key (kbd "C-z") 'undo-fu-only-undo)
+;; originally: suspend-emacs (might want to call manually in tty sometimes)
;;;;; C-M-z - suspend-frame
(global-set-key (kbd "C-M-z") 'suspend-frame)
;; this is never good in a gui
(global-set-key (kbd "C-s") 'kill-region)
-;;;;; M-x - counsel-m-x
+;;;;; M-x - m-x
-;; todo; check out smex-show-unbound-commands shows frequently used commands that have no key bindings.
-;; this must be before smex-initialize
-(setq
- smex-save-file (concat user-emacs-directory ".smex-items"))
-
-;; this uses smex
-(global-set-key (kbd "M-x") 'counsel-M-x)
-
;;;;; C-M-x - cut-to-register
;; same args as copy-to-register
(global-set-key (kbd "C-d") 'kill-ring-save)
-;; by default is does image-dired-delete-character, pretty useless.
+;; by default is does image-dired-delete-character (stops displaying its thumbnail), pretty useless.
(add-hook 'image-dired-thumbnail-mode-hook
(lambda ()
+ (define-key image-dired-thumbnail-mode-map (kbd ",") 'image-dired-copy-filename-r1)
+ (define-key image-dired-thumbnail-mode-map (kbd ".") 'image-dired-copy-filename-r2)
+ (define-key image-dired-thumbnail-mode-map (kbd "/") 'image-dired-copy-filename-r3)
+ (define-key image-dired-thumbnail-mode-map (kbd "k") 'image-dired-copy-filename-r4)
+ (define-key image-dired-thumbnail-mode-map (kbd "l") 'image-dired-copy-filename-r5)
+ (define-key image-dired-thumbnail-mode-map (kbd "u") 'image-dired-copy-filename-ban)
+ (define-key image-dired-thumbnail-mode-map (kbd "y") 'image-dired-copy-filename-draw)
+ (define-key image-dired-thumbnail-mode-map (kbd "h") 'image-dired-copy-filename-tame)
+ (define-key image-dired-thumbnail-mode-map (kbd "o") 'image-dired-copy-filename-tbdremix)
+ (define-key image-dired-thumbnail-mode-map (kbd "n") 'image-dired-copy-filename-remix)
(define-key image-dired-thumbnail-mode-map (kbd "C-d") nil)))
(global-set-key (kbd "C-v") 'yank-better)
-(add-hook 'ivy-mode-hook
- (lambda ()
- (define-key ivy-minibuffer-map (kbd "C-v") nil)))
(global-set-key (kbd "C-o") 'occur)
-;;;;; C-M-o - counsel-imenu
+;;;;; C-M-o - imenu
-(global-set-key (kbd "C-M-o") 'counsel-imenu)
+(global-set-key (kbd "C-M-o") 'imenu)
+;; note: previously: counsel-imenu
;;;;; C-p - move-mouse-to-point
(global-set-key (kbd "C-M-k") 'man)
-;;;;; C-l - ivy-switch-buffer
+;;;;; C-l - switch-buffer
-(global-set-key (kbd "C-l") 'ivy-switch-buffer)
+(global-set-key (kbd "C-l") 'switch-to-buffer)
+;; was ivy-switch-buffer
;;;;; C-M-l - move cursor top bottom mid, comint clear screen
(add-hook 'flyspell-mode-hook
(lambda () (define-key flyspell-mode-map (kbd "C-.") nil)))
(define-key dot-mode-map (kbd "C-.") nil)
-(define-key terminal-key-map (kbd "4c") 'counsel-recentf)
-(global-set-key (kbd "C-.") 'counsel-recentf)
+(define-key terminal-key-map (kbd "4c") 'recentf)
+(global-set-key (kbd "C-.") 'recentf)
(add-hook 'php-mode-hook
(lambda () (define-key php-mode-map (kbd "C-.") nil)))
+;; note: previously counsel-recentf
;;;;; C-M-. - -
(global-set-key (kbd "<C-S-kp-enter>") 'winner-redo)
-;;;;; C-S-down-arrow - m-x for major mode
+;;;;; C-S-down-arrow - unused (text-scale-increase)
-;; todo, update this for ivy
-(global-set-key (kbd "<C-S-kp-enter>") 'smex-major-mode-commands)
+;; Disabled cuz i never ended up sing it
+;; todo, update this for ivy or whatever else
+;; (global-set-key (kbd "<C-S-kp-enter>") 'smex-major-mode-commands)
;;;;; C-lbracket - ----
;;;;; C-M-lbracket - scroll-right