diff --git a/.config/emacs/Emacs@256.png b/.config/emacs/Emacs@256.png new file mode 100644 index 0000000..43d2a0c Binary files /dev/null and b/.config/emacs/Emacs@256.png differ diff --git a/.config/emacs/elisp/welcome.el b/.config/emacs/elisp/welcome.el new file mode 100644 index 0000000..63195af --- /dev/null +++ b/.config/emacs/elisp/welcome.el @@ -0,0 +1,133 @@ +;;; welcome.el --- A dashboard that welcomes you! -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Joseph Ferano + +;; Author: Joseph Ferano +;; Keywords: init, welcome, dashboard, startup + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Something something minimalism and dasboards + +;;; Code: + + +;; (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 welcome-load-project-map (make-sparse-keymap) + "High precedence keymap.") + +(defun 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) + +;; +;; Look into (text-property-search-forward) +;; (text-property-search-backward) +;; + +(defun welcome--load-bookmarks () + (with-temp-buffer + (if (file-exists-p bookmark-file) + (progn + (insert-file-contents bookmark-file) + (goto-char (point-min)) + (let ((bmarks (read (current-buffer)))) + (mapcar (lambda (bm) (cons (car bm) (cdr (nth 1 bm)))) bmarks))) + (list '("No Bookmark Fls"))))) + +(defun welcome--load-projects () + (with-temp-buffer + (insert-file-contents project-list-file) + (goto-char (point-min)) + (let ((contents (apply #'append (read (current-buffer))))) + (if contents + (seq-subseq contents 0 (min (length contents) 4)) + "No Projects")))) + +(defun welcome--recent-files () + (with-temp-buffer + (insert-file-contents recentf-save-file) + (goto-char (point-min)) + (let ((contents (apply #'append (read (current-buffer))))) + (if contents + (seq-subseq contents 0 (min (length contents) 8)) + "No Recent Files")))) + +(defun welcome--recent-files () + (if recentf-list + (seq-subseq recentf-list 0 (min (length recentf-list) 8)) + "No Recent Files")) + +(defun welcome--render-dash () + "Show Welcome buffer" + (with-current-buffer (get-buffer-create "*Welcome*") + (buffer-size) + (erase-buffer) + (goto-char (point-min)) + (insert-image (create-image "/home/joe/.config/emacs/elisp/Emacs@256.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 (welcome--load-projects)) + (insert (format "\t%s\n" proj))) + (insert "\nRecent Files:\n") + (dolist (file (welcome--recent-files)) + (insert (format "\t%s\n" file))) + (insert "\nBookmarks:\n") + (dolist (bmark (welcome--load-bookmarks)) + (insert (format "\t%s - %s\n" (car bmark) (cdr bmark)))) + ;; (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 #'welcome--render-dash) + +(provide 'welcome) +;;; welcome.el ends here diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 11593e9..18360ef 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -2947,7 +2947,7 @@ over as explained [[https://manueluberti.eu/2018/02/17/magit-bury-buffer.html][h ** Initial Buffer #+begin_src emacs-lisp -(load-file "/home/joe/Dotfiles/.config/emacs/elisp/welcome.el") +(load-file "/home/joe/.config/emacs/elisp/welcome.el") #+end_src * COMMENT Local variables diff --git a/.gitignore b/.gitignore index f0d41af..fbaa5f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ .config/emacs/* !.config/emacs/init.org +!.config/emacs/elisp/ +!.config/emacs/elisp/welcome.el +!.config/emacs/Emacs@256.png /.config/nvim/plugin/ .config/magit/* !.config/magit/init.el