Move welcome to another file. Random stuff and embark

This commit is contained in:
Joseph Ferano 2023-05-07 12:14:21 +07:00
parent 3ddf540c59
commit 0a5b7aa497
2 changed files with 85 additions and 113 deletions

View File

@ -374,7 +374,7 @@ Setup other stuff
(add-to-list 'default-frame-alist '(fullscreen . maximized)) (add-to-list 'default-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(vertical-scroll-bars . nil)) (add-to-list 'default-frame-alist '(vertical-scroll-bars . nil))
(add-hook 'text-mode-hook (lambda () (setq fill-column 100) (turn-on-auto-fill))) (add-hook 'text-mode-hook (lambda () (setq fill-column 80) (turn-on-auto-fill)))
(setq-default display-line-numbers 'relative) (setq-default display-line-numbers 'relative)
(make-variable-buffer-local 'global-hl-line-mode) (make-variable-buffer-local 'global-hl-line-mode)
@ -784,76 +784,6 @@ weren't working, until I randomly saw this in someone's init.el
(setq evil-goggles-pulse t) (setq evil-goggles-pulse t)
(setq evil-goggles-async-duration 0.55) (setq evil-goggles-async-duration 0.55)
#+end_src
** Initial Buffer
#+begin_src emacs-lisp
;; (require 'dashboard)
;; (defun dashboard-center-text (start end)
;; "Center the text between START and END."
;; (save-excursion
;; (goto-char start)
;; (let ((width 0))
;; (while (< (point) end)
;; (let* ((line-str (buffer-substring (line-beginning-position) (line-end-position)))
;; (line-length (dashboard-str-len line-str)))
;; (setq width (max width line-length)))
;; (forward-line 1))
;; (let ((prefix (propertize " " 'display `(space . (:align-to (- center ,(/ width 2)))))))
;; (add-text-properties start end `(line-prefix ,prefix indent-prefix ,prefix))))))
;; (defun dashboard-insert-center (&rest strings)
;; "Insert STRINGS in the center of the buffer."
;; (let ((start (point)))
;; (apply #'insert strings)
;; (dashboard-center-text start (point))))
(defvar joe/welcome-load-project-map (make-sparse-keymap)
"High precedence keymap.")
(defun joe/welcome-open-project ()
"Open the directory at point in dired."
(interactive)
(let ((path (file-truename (substring-no-properties
(thing-at-point 'filename)))))
(project-switch-project path)))
;; (evil-define-key 'normal 'joe/welcome-load-project-map (kbd "RET") #'joe/welcome-open-project)
(defun load-projects ()
(with-temp-buffer
(insert-file-contents project-list-file)
(goto-char (point-min))
(apply #'append (read (current-buffer)))))
(defun my-dashboard ()
"Show Welcome buffer"
(with-current-buffer (get-buffer-create "*Welcome*")
(erase-buffer)
(goto-char (point-min))
(insert-image (create-image "~/Documents/emacs-alt.png"))
(insert "\n\n\n")
(insert "Welcome to Emacs!\n\n")
;; (dashboard-insert-center "testing this thing out\n\n")
(let* ((time-str (emacs-init-time))
(time (string-to-number (car (split-string time-str)))))
(insert (format "It took %.3f seconds to start up\n\n" time)))
(insert "Happy hacking!\n\n")
(insert "Projects:\n")
(dolist (proj (load-projects))
(insert (format "\t%s\n" proj)))
;; (insert (propertize (format "\t%s\n" proj) :keymap joe/welcome-load-project-map)))
(setq cursor-type nil)
(switch-to-buffer (current-buffer))
(goto-char 86)
(display-line-numbers-mode 0)
(olivetti-mode)
(read-only-mode +1)
(current-buffer)))
(setq initial-buffer-choice #'my-dashboard)
#+end_src #+end_src
** Buffers ** Buffers
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -917,6 +847,14 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(global-set-key (kbd "s-k") #'windmove-up) (global-set-key (kbd "s-k") #'windmove-up)
(global-set-key (kbd "s-j") #'windmove-down) (global-set-key (kbd "s-j") #'windmove-down)
;; There's a bug in Gnome where frames are resized to the wrong dimensions
(defun joe/resize-frames ()
(interactive)
(dolist (frame (frame-list))
(toggle-frame-maximized frame)
(toggle-frame-maximized frame)))
(global-set-key (kbd "s-<f10>") #'joe/resize-frames)
#+end_src #+end_src
Ace Window will show a hint if there are more than 2 windows, but I don't really use it Ace Window will show a hint if there are more than 2 windows, but I don't really use it
@ -986,7 +924,6 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really
(add-to-list 'consult-buffer-sources 'beframe-consult-source)) (add-to-list 'consult-buffer-sources 'beframe-consult-source))
(beframe-mode +1) (beframe-mode +1)
#+end_src #+end_src
*** Popper *** Popper
@ -997,6 +934,7 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really
"^\\*vterm\\*" vterm-mode "^\\*vterm\\*" vterm-mode
"^\\*Flymake.*" flymake-mode "^\\*Flymake.*" flymake-mode
"^\\*Flycheck.*" flycheck-error-list-mode "^\\*Flycheck.*" flycheck-error-list-mode
"^\\*Occur\\*$" occur-mode
"^\\*lsp-help\\*" lsp-help-mode "^\\*lsp-help\\*" lsp-help-mode
"^\\*eldoc\\*" special-mode "^\\*eldoc\\*" special-mode
"^\\*ert\\*" ert-results-mode "^\\*ert\\*" ert-results-mode
@ -1389,11 +1327,34 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'embark) (require 'embark)
;; TODO Prot ;; TODO Try using embark to kill this buffer
;; 1.) Cannot quickly deleete buffers from the mini buffer with emark (defun prot-simple-kill-buffer-current (&optional arg)
;; 2.) switch-to-buffer-other-frame is not working "Kill current buffer.
With optional prefix ARG (\\[universal-argument]) delete the
buffer's window as well."
(interactive "P")
(let ((kill-buffer-query-functions nil))
(if (and arg (not (one-window-p)))
(kill-buffer-and-window)
(kill-buffer))))
(defun prot-simple-kill-buffer (buffer)
"Kill current BUFFER.
When called interactively, prompt for BUFFER."
(interactive (list (read-buffer "Select buffer: ")))
(let ((kill-buffer-query-functions nil))
(kill-buffer (or buffer (current-buffer)))))
(setq embark-quit-after-action '((kill-buffer . nil))) (setq embark-quit-after-action '((kill-buffer . nil)))
;; TODO Add this to display-buffer-alist
;; ("\\*Embark Actions\\*"
;; (display-buffer-reuse-mode-window display-buffer-at-bottom)
;; (window-height . fit-window-to-buffer)
;; (window-parameters . ((no-other-window . t)
;; (mode-line-format . none))))
;; TODO Remove the which-key stuff because it seems to be breaking things
(defun embark-which-key-indicator () (defun embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key. "An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the The which-key help message will show the type and value of the
@ -1431,7 +1392,7 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really
(advice-add #'embark-completing-read-prompter (advice-add #'embark-completing-read-prompter
:around #'embark-hide-which-key-indicator) :around #'embark-hide-which-key-indicator)
(advice-remove #'embark-completing-read-prompter #'embark-hide-which-key-indicator)
#+end_src #+end_src
*** Marginalia *** Marginalia
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -1676,8 +1637,13 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(setq mono-complete-backend-capf-complete-fn #'eglot-completion-at-point) (setq mono-complete-backend-capf-complete-fn #'eglot-completion-at-point)
(setq mono-complete-preview-delay 0.1) (setq mono-complete-preview-delay 0.1)
;; TODO Prot This setting gets lost when creating a new frame ;; (add-to-list 'face-remapping-alist '(mono-complete-preview-face . shadow))
(add-to-list 'face-remapping-alist '(mono-complete-preview-face . shadow))
(set-face-attribute 'mono-complete-preview-face nil
:foreground 'unspecified
:background 'unspecified
:inherit 'shadow)
(mono-complete-mode +1) (mono-complete-mode +1)
#+end_src #+end_src
*** Eldoc *** Eldoc
@ -1923,7 +1889,7 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(defun joe/sql-mode-hook () (defun joe/sql-mode-hook ()
(define-key sql-mode-map (kbd "C-M-h") #'joe/mark-sql-defun) (define-key sql-mode-map (kbd "C-M-h") #'joe/mark-sql-defun)
(define-key sql-mode-map (kbd "C-M-x") #'sql-send-pg-function) (define-key sql-mode-map (kbd "C-M-x") #'sql-send-pg-function)
(define-key sql-mode-map (kbd "<f8>") #'sql-connect)) (global-set-key (kbd "<f8>") #'sql-connect))
(add-hook 'sql-mode-hook #'joe/sql-mode-hook) (add-hook 'sql-mode-hook #'joe/sql-mode-hook)
@ -2096,7 +2062,7 @@ and there's no need for a middle-man when it's already been implemented.
#+end_src #+end_src
** Magit ** Magit
The best git porcelain/client I've ever used. Also kill stray magit buffers left over as explained [[https://manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/][here]] The best git porcelain/client I've ever used. Also kill stray magit buffers left over as explained [[https://manueluberti.eu/2018/02/17/magit-bury-buffer.html][here]]
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'magit) (require 'magit)
@ -2130,7 +2096,11 @@ The best git porcelain/client I've ever used. Also kill stray magit buffers left
#+end_src #+end_src
** Initial Buffer
#+begin_src emacs-lisp
(load-file "/home/joe/Dotfiles/.config/emacs/elisp/welcome.el")
#+end_src
* COMMENT Local variables * COMMENT Local variables
;; Local Variables: ;; Local Variables:

View File

@ -3,6 +3,7 @@
SETUVAR --export CARGO_HOME:/home/joe/\x2elocal/share/bin/cargo/ SETUVAR --export CARGO_HOME:/home/joe/\x2elocal/share/bin/cargo/
SETUVAR EDITOR:hx SETUVAR EDITOR:hx
SETUVAR --export LC_COLLATE:C SETUVAR --export LC_COLLATE:C
SETUVAR --export --path LD_LIBRARY_PATH:/usr/local/lib
SETUVAR --export PYTHONSTARTUP:/etc/python/pythonrc SETUVAR --export PYTHONSTARTUP:/etc/python/pythonrc
SETUVAR --export RUSTUP_HOME:/home/joe/\x2elocal/share/rustup/ SETUVAR --export RUSTUP_HOME:/home/joe/\x2elocal/share/rustup/
SETUVAR XDG_CACHE_HOME:/home/joe/\x2ecache SETUVAR XDG_CACHE_HOME:/home/joe/\x2ecache
@ -32,6 +33,7 @@ SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrbl
SETUVAR fish_color_status:red SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_greeting:
SETUVAR fish_key_bindings:fish_default_key_bindings SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_completion:normal SETUVAR fish_pager_color_completion:normal
SETUVAR fish_pager_color_description:B3A06D\x1eyellow SETUVAR fish_pager_color_description:B3A06D\x1eyellow