;; -*- lexical-binding: t; -*- #+startup: content #+title: Emacs literate configuration #+author: yaidel #+date: [2022-12-08 Thu] * Interface tweaks First of all, avoid the output of =custom-set-variables= to the =~/.emacs.d/init.el= file. This some times writes there some customization which interferes with those made in this file. I have had some rough times debugging stuffs because they were defined automatically by Emacs in the =custom-set-variables= section of the =init= file. #+begin_src emacs-lisp (setq-default custom-file null-device) #+end_src Then, inhibit the startup bottom buffer. If someone like it just comment the following block. #+begin_src emacs-lisp (setq inhibit-startup-message t) #+end_src Disable menubar, scrollbar, toolbar and fringe: #+begin_src emacs-lisp (menu-bar-mode -1) (tool-bar-mode -1) ;; (fringe-mode -1) (scroll-bar-mode -1) (customize-set-variable 'scroll-bar-mode nil) (customize-set-variable 'horizontal-scroll-bar-mode nil) #+end_src Some key-bindings I use (see [[https://www.emacswiki.org/emacs/LineNumbers][this page]] for line-numbers configuration) #+begin_src emacs-lisp (global-set-key (kbd "") 'revert-buffer) (global-set-key (kbd "") 'eshell) (global-set-key (kbd "") 'display-line-numbers-mode) #+end_src Show line numbers by default in programming mode #+begin_src emacs-lisp ;; (add-hook 'prog-mode-hook #'display-line-numbers-mode) #+end_src Use spaces instead of TABS #+begin_src emacs-lisp (setq-default indent-tabs-mode nil) #+end_src ** Window startup geometry Here the frame can start maximized with the following option #+begin_src emacs-lisp ;; (add-hook 'window-setup-hook 'toggle-frame-maximized t) #+end_src Or it can be set to a certain geometry with the following options #+begin_src emacs-lisp (setq default-frame-alist '((top . 60) (left . 150) (width . 160) (height . 42))) #+end_src ** Theme One theme I used for a long time was Leuven which can be loaded with ~(load-theme 'leuven t)~, however [[https://protesilaos.com/][Protesilaos]]' themes are really nice alternatives which have been gratefully welcomed in the Emacs comunity. In my case I am using the =ef-themes= because they are really colorful (in a balanced maner). Other Prot's packages complement the theme: #+begin_src emacs-lisp (use-package ef-themes :ensure t :init (mapc #'disable-theme custom-enabled-themes) :config (setq ef-themes-mixed-fonts t ef-themes-variable-pitch-ui t) ;; Load the theme of choice: (load-theme 'ef-light :no-confirm) ) #+end_src #+begin_src emacs-lisp (use-package spacious-padding :ensure t :config (spacious-padding-mode 1) ) #+end_src The following code was provided by Prot, and it is needed to make =spacious-padding= remove the black borders it creates when Emacs is run with the daemon. #+begin_src emacs-lisp (defun my-spacious-padding-remove-borders (_) (spacious-padding-modify-frame-parameters nil) (spacious-padding-set-invisible-dividers nil)) (add-hook 'after-make-frame-functions #'my-spacious-padding-remove-borders) #+end_src #+begin_src emacs-lisp (use-package fontaine :ensure t :config (setq fontaine-latest-state-file (locate-user-emacs-file "fontaine-latest-state.eld")) (setq fontaine-presets '((tiny :default-family "Iosevka Comfy Wide Fixed" :default-height 70) (small :default-family "Iosevka Comfy Fixed" :default-height 90) (regular :default-height 130) (medium :default-height 150) (large :default-weight semilight :default-height 170 :bold-weight extrabold) (presentation :default-weight semilight :default-height 170 :bold-weight extrabold) (jumbo :default-weight semilight :default-height 220 :bold-weight extrabold) (t ;; I keep all properties for didactic purposes, but most can be ;; omitted. See the fontaine manual for the technicalities: ;; . :default-family "Iosevka Comfy" :default-weight regular :default-height 100 :fixed-pitch-family nil ; falls back to :default-family :fixed-pitch-weight nil ; falls back to :default-weight :fixed-pitch-height 1.0 :fixed-pitch-serif-family nil ; falls back to :default-family :fixed-pitch-serif-weight nil ; falls back to :default-weight :fixed-pitch-serif-height 1.0 :variable-pitch-family "Iosevka Comfy Duo" :variable-pitch-weight nil :variable-pitch-height 1.0 :bold-family nil ; use whatever the underlying face has :bold-weight bold :italic-family nil :italic-slant italic :line-spacing nil))) ;; Recover last preset or fall back to desired style from ;; `fontaine-presets'. (fontaine-set-preset (or (fontaine-restore-latest-preset) 'regular)) ;; The other side of `fontaine-restore-latest-preset'. (add-hook 'kill-emacs-hook #'fontaine-store-latest-preset) ) #+end_src #+begin_src emacs-lisp (use-package pulsar :ensure t :config (setq pulsar-pulse t) (setq pulsar-delay 0.075) (setq pulsar-iterations 10) (setq pulsar-face 'pulsar-magenta) (setq pulsar-highlight-face 'pulsar-yellow) (pulsar-global-mode 1) ) #+end_src #+BEGIN_SRC emacs-lisp (use-package lin :ensure t :config (setq lin-face 'lin-mac-override-fg) (setq lin-mode-hooks (append lin-mode-hooks '(prog-mode-hook org-mode-hook))) (lin-global-mode 1) ) #+END_SRC ** UTF-8 encoding: #+BEGIN_SRC emacs-lisp (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) #+END_SRC ** Change 'yes or no' prompts to 'y or n': #+BEGIN_SRC emacs-lisp (fset 'yes-or-no-p 'y-or-n-p) #+END_SRC ** Auto-fill-mode for text based buffers We could use only the following block to achieve auto fill. This would, however, automatically break the line and start a new one when column =fill-column= is reached. I used to use this for some time, but afterwards I needed to move the text to another application, and it was all filled with line breaks which I had to remove by hand. There is probably a smart and convenient way to remove those end-of-line, but I am not aware of it. #+begin_src emacs-lisp ;; (add-hook 'text-mode-hook 'auto-fill-mode) #+end_src Instead of actually changing the text of the buffer by introducing end-of-lines when using =auto-fill-mode=, it is possible to use the option =visual-line-mode=. This mode will take the text in the edge and simulate as if there were a end-of-line, i.e. the line will be broken, but in reality it is just a visual effect, the line in the underlying file has not end-of-line. =visual-line-mode= comes built in Emacs, and I call it when loading the packages where I want it to be present, like org-mode, for example. Next code line activates =visual-line-mode= globally in case you find it fancy: #+begin_src emacs-lisp ;; (global-visual-line-mode 1) #+end_src The behavior achieved by =visual-line-mode= can be extended to be more like =auto-fill-mode=, i.e. to restrict the column to which the text is displayed as maximum. That can be achieved with the package =visual-fill-column=. [[https://github.com/joostkremers/visual-fill-column][This package]] makes possible that instead of wrapping lines at the window edge, which is the standard behavior of =visual-line-mode=, it wraps lines at =fill-column=. Just what one may want: #+begin_src emacs-lisp (use-package visual-fill-column :ensure t ) #+end_src #+begin_src emacs-lisp (global-set-key (kbd "") 'visual-fill-column-mode) #+end_src Next we set the columns number where to cut #+begin_src emacs-lisp (setq-default fill-column 110) (setq column-number-mode t) #+end_src However, I have noticed that =visual-fill-column= *has some conflicts with org-mode* documents using =org-indent-mode=. The indentation just doesn't work as expected. For that reason I prefer to just assign it a keybinding and call it when need it. So far I have not called it even once. And finally, we could use the =adaptive-wrap= package to avoid that the next line, when artificially broken by =visual-fill-column=, be more on the left than its parent, in case the parent was indented. #+begin_src emacs-lisp ;; (use-package adaptive-wrap ;; :ensure t ;; :after visual-fill-column ;; :hook ;; (visual-line-mode . adaptive-wrap-prefix-mode) ;; :config ;; (setq-default adaptive-wrap-extra-indent 0) ;; ) #+end_src ** Edit the configuration file Set =C-c e= to edit this file: #+BEGIN_SRC emacs-lisp (defun config-visit () (interactive) (find-file "~/config/dotFiles/emacs_init/dot_emacs.org")) (global-set-key (kbd "C-c e") 'config-visit) #+END_SRC Reload the configuration from this file when =C-c r= is pressed: #+BEGIN_SRC emacs-lisp (defun config-reload () "Reloads ~/.emacs.d/config.org at runtime" (interactive) (org-babel-load-file (expand-file-name "~/config/dotFiles/emacs_init/dot_emacs.org"))) (global-set-key (kbd "C-c r") 'config-reload) #+END_SRC * Windows management #+BEGIN_SRC emacs-lisp (use-package ace-window :ensure t :init (progn (global-set-key [remap other-window] 'ace-window) (custom-set-faces '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) )) ;; (global-set-key (kbd "M-o") 'ace-window) #+END_SRC Winner is a global minor mode built into Emacs that records the changes in the window configuration. It basically provides two functions: 1. =winner-undo=, by default bind to =C-c left=. 2. =winner-redo=, by default bind to =C-c right=. Let's say we have a frame with one window (state 1), and we split it vertically (state 2) and then horizontally (state 3). If we call =winner-undo=, we will undo the last modification we did to the frame, which means that we will have two vertical windows (return to state 2). If we call once more =winner-undo=, we will return to the first state, with only one window in the frame. Then, we can return to state 3 by invoking =winner-redo= two times. To enable =winner-mode= we need to customize the variable as follows: #+begin_src emacs-lisp (winner-mode 1) #+end_src See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Window-Convenience.html#index-winner_002dmode][official GNU/Emacs documentation]] or the [[https://www.emacswiki.org/emacs/WinnerMode][Emacs Wiki dedicated page]]. * Searching and helping to find things ** Vertico configuration #+begin_src emacs-lisp (use-package vertico :ensure t :init (vertico-mode +1) ;; Different scroll margin ;; (setq vertico-scroll-margin 0) ;; Show more candidates ;; (setq vertico-count 20) ;; Grow and shrink the Vertico minibuffer ;; (setq vertico-resize t) ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. ;; (setq vertico-cycle t) ) #+end_src ** Savehist configuration #+begin_src emacs-lisp (use-package savehist :ensure t :init (savehist-mode)) #+end_src ** Orderless configuration #+begin_src emacs-lisp (use-package orderless :ensure t :init ;; Configure a custom style dispatcher (see the Consult wiki) ;; (setq orderless-style-dispatchers '(+orderless-dispatch) ;; orderless-component-separator #'orderless-escapable-split-on-space) (setq completion-styles '(orderless) completion-category-defaults nil completion-category-overrides '((file (styles partial-completion)))) ) #+end_src ** Consult configuration #+begin_src emacs-lisp (use-package consult :ensure t ;; Enable automatic preview at point in the *Completions* buffer. This is ;; relevant when you use the default completion UI. :hook (completion-list-mode . consult-preview-at-point-mode) ;; The :init configuration is always executed (Not lazy) :init ;; Optionally configure the register formatting. This improves the register ;; preview for `consult-register', `consult-register-load', ;; `consult-register-store' and the Emacs built-ins. (setq register-preview-delay 0.5 register-preview-function #'consult-register-format) ;; Optionally tweak the register preview window. ;; This adds thin lines, sorting and hides the mode line of the window. (advice-add #'register-preview :override #'consult-register-window) ;; Use Consult to select xref locations with preview (setq xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref) ) #+end_src ** Marginalia configuration #+begin_src emacs-lisp (use-package marginalia :ensure t ;; Either bind `marginalia-cycle` globally or only in the minibuffer :bind (("M-A" . marginalia-cycle) :map minibuffer-local-map ("M-A" . marginalia-cycle)) ;; The :init configuration is always executed (Not lazy!) :init ;; Must be in the :init section of use-package such that the mode gets ;; enabled right away. Note that this forces loading the package. (marginalia-mode)) #+end_src ** Embark configuration #+begin_src emacs-lisp (use-package embark :ensure t :bind (("C-}" . embark-act) ;; pick some comfortable binding ("C-;" . embark-dwim) ;; good alternative: M-. ("C-h B" . embark-bindings) ;; alternative for `describe-bindings' ("M-o" . embark-export)) :init ;; Optionally replace the key help with a completing-read interface (setq prefix-help-command #'embark-prefix-help-command) :config ;; Hide the mode line of the Embark live/completions buffers (add-to-list 'display-buffer-alist '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" nil (window-parameters (mode-line-format . none))))) ;; Consult users will also want the embark-consult package. (use-package embark-consult :ensure t :after (embark consult) :demand t ; only necessary if you have the hook below ;; if you want to have consult previews as you move around an ;; auto-updating embark collect buffer :hook (embark-collect-mode . consult-preview-at-point-mode)) #+end_src * General packages ** Dired The Dired documentation can be found by =C-h m= on the buffer, ot at [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired.html][the GNU manual]]. List directories before files: #+BEGIN_SRC emacs-lisp (defun mydired-sort () "Sort dired listings with directories first." (save-excursion (let (buffer-read-only) (forward-line 2) ;; beyond dir. header (sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max))) (set-buffer-modified-p nil))) (defadvice dired-readin (after dired-after-updating-hook first () activate) "Sort dired listings with directories first before adding marks." (mydired-sort)) #+END_SRC Show file sizes in KB, MB, GB instead of just bytes: #+BEGIN_SRC emacs-lisp (setq-default dired-listing-switches "-alh") #+END_SRC Delete the previous buffer each time a new folder is entered. This way you do not end up with several buffers opened, one for each folder you visited. #+begin_src emacs-lisp (setq dired-kill-when-opening-new-dired-buffer t) #+end_src Ask for the creation of destination folders which do not exist. #+begin_src emacs-lisp (setq dired-create-destination-dirs "ask") #+end_src Hide dotfiles by default, and add =super + h= keybinding to toggle: #+BEGIN_SRC emacs-lisp ;; (add-hook 'dired-load-hook #'(lambda () (require 'dired-x))) ; Load Dired X when Dired is loaded. ;; (setq dired-omit-mode t) ; Turn on Omit mode. ;; (require 'dired-x) ;; (setq-default dired-omit-files-p t) ; Buffer-local variable ;; (setq dired-omit-files (concat dired-omit-files "\\|^\\..+$")) ;; ;; keybinding toggle ;; (define-key dired-mode-map (kbd "s-h") 'dired-omit-mode) #+END_SRC ** Elfeed :PROPERTIES: :ID: 4529071a-2ea8-4299-90b9-0593cc31ecda :END: Load elfeed #+begin_src emacs-lisp ;; the database is strored in ~/.elfeed by default ;; after remove an rss, if you want to remove old entries from it, just delete the database with emacs shuted down (use-package elfeed :ensure t :init (setq elfeed-db-directory "~/config/elfeed/elfeeddb") :bind (("C-x w" . elfeed)) :config ;; Personalized authors list (add-hook 'elfeed-search-mode-hook 'elfeed-update) ;;(setq elfeed-search-title-max-width 100) (setq elfeed-search-filter "@2-week-ago +unread")) #+end_src Load elfeed-org to allow rss feeds to be set up with an org file: (It is important to note that each 1st heading need to have the tag =elfeed= in order to be correctly parsed by the =elfeed-org= package. This means that all the entries have the =elfeed= tag.) #+begin_src emacs-lisp (use-package elfeed-org :ensure t :config (elfeed-org) (setq rmh-elfeed-org-files (list "~/config/dotFiles/elfeed.org")) ) #+end_src Download video of the feed in the folder ~/Videos directly with the key binding =d= #+begin_src emacs-lisp (defun ytg/yt-dl-it (url) "Downloads the URL in an async shell" (let ((default-directory "~/Videos")) (async-shell-command (format "yt-dlp %s" url)))) (defun ytg/elfeed-youtube-dl (&optional use-generic-p) "Youtube-DL link" (interactive "P") (let ((entries (elfeed-search-selected))) (cl-loop for entry in entries ;;do (elfeed-untag entry 'unread) when (elfeed-entry-link entry) do (ytg/yt-dl-it it)) (mapc #'elfeed-search-update-entry entries) (unless (use-region-p) (forward-line)))) (define-key elfeed-search-mode-map (kbd "d") 'ytg/elfeed-youtube-dl) #+end_src Start reproducing the video of the feed with the key =v= #+begin_src emacs-lisp (defun ytg/elfeed-v-mpv (url) "Watch a video from URL in MPV" (async-shell-command (format "mpv %s" url))) (defun ytg/elfeed-view-mpv (&optional use-generic-p) "Youtube-feed link" (interactive "P") (let ((buffer (current-buffer)) (entries (elfeed-search-selected))) (cl-loop for entry in entries do (elfeed-untag entry 'unread) when (elfeed-entry-link entry) do (ytg/elfeed-v-mpv it)) (mapc #'elfeed-search-update-entry entries) (unless (use-region-p) (forward-line)))) (define-key elfeed-search-mode-map (kbd "v") 'ytg/elfeed-view-mpv) #+end_src Appearance settings: #+BEGIN_SRC emacs-lisp ;; (setq-default elfeed-initial-tags nil) ;; (setq-default elfeed-search-date-format (quote ("%a, %R" 10 :left))) ;; (setq-default elfeed-curl-max-connections 100) ;; (setq-default elfeed-search-trailing-width 30) #+END_SRC ** Org-capture in Elfeed configuration When I am reading an article in [[id:4529071a-2ea8-4299-90b9-0593cc31ecda][Elfeed]], sometimes some idea popup and I want to capture it. Normally, I would have to manually copy the link, and then open the regular capture template I have and make the capture of the idea. What the following function does is to automate the copying part. The variable ~org-store-link-functions~ is set to ~ytg/org-elfeed-entry-store-link~, so in the =org-capture-template= dedicated to this purpose we can use =%a= to [[https://orgmode.org/manual/Template-expansion.html][retrieve the stored link]]. See the =org-capture-template= =Read later / take a note= on the section [[id:ebdfd897-7542-44e6-8413-632b41e7fb32][Org mode]] which makes use of this functions and hook by using =%a=, as previously explained. This solution was taken from [[https://yiming.dev/blog/2016/01/28/add-org-store-link-entry-for-elfeed/][this post of Yiming Chen]]. #+begin_src emacs-lisp (defun ytg/org-elfeed-entry-store-link () (when elfeed-show-entry (let* ((link (elfeed-entry-link elfeed-show-entry)) (title (elfeed-entry-title elfeed-show-entry))) (org-store-link-props :link link :description title) ))) (add-hook 'org-store-link-functions 'ytg/org-elfeed-entry-store-link) #+end_src ** Which-key When typing in the M-x, it shows a list of possibilities #+BEGIN_SRC emacs-lisp (use-package which-key :ensure t :config (which-key-mode)) #+END_SRC ** Try #+begin_src emacs-lisp (use-package try :ensure t ) #+end_src * Org-mode links integration with Thunderbird Some years ago it was possible to use the [[https://github.com/mikehardy/thunderlink][Thunderlink]] plugin to obtain a "link" to a specific email, and when you clicked that link it would open Thunderbird with a focus on the required email. However, that project died. Fortunately, [[https://camiel.bouchier.be/en/about-me][Camiel Bouchier]] made the necessary re-writing of the code need to make it work with newer versions of Thunderbird's API, in what it's called [[https://github.com/CamielBouchier/cb_thunderlink][cb_thunderlink]]. For the time of writing ([2023-08-26 Sat]) it is still maintained, let's hope it keeps that way. The (sort of) documentation for the plugin is on [[https://camiel.bouchier.be/en/cb_thunderlink][this post]] of Camiel's website. And to use it in conjunction with Emacs it is also needed an Elisp workaround to tell emacs how to respond when =org-open-at-point= is executed on one of =cb_thunderlink='s link. 1) The installation of the =cb_thunderlink= plugin is straightforward in the Thunderbird Plugin Store. 2) The workaround, on the other hand, I got from [[https://vxlabs.com/][vxlabs]]' website, where he explains how to [[https://vxlabs.com/2019/04/20/link-thunderbird-emails-from-emacs-orgmode/][Link directly to emails from Emacs Orgmode using Thunderbird and Thunderlink]]. As you may have noticed, the workaround was written for =thunderlink=, not for =cb_thunderlink=, so I have made some modifications to it. Also, there was a conditional to check if the system was Mac or not, I removed that part too as I do not need it. See the code below: #+begin_src emacs-lisp (setq thunderbird-program "thunderbird") (defun org-message-thunderlink-open (slash-message-id) "Handler for org-link-set-parameters that converts a standard message:// link into a thunderlink and then invokes thunderbird." ;; remove any / at the start of slash-message-id to create real message-id (let ((message-id (replace-regexp-in-string (rx bos (* "/")) "" slash-message-id))) (kill-new (concat "cbthunderlink://" message-id)) (start-process (concat "cbthunderlink: " message-id) nil thunderbird-program "-cbthunderlink" (concat "cbthunderlink://" message-id) ))) ;; on message://aoeu link, this will call handler with //aoeu (org-link-set-parameters "message" :follow #'org-message-thunderlink-open) #+end_src A link generated with =cb_thunderlink= looks something like this: #+begin_example cbthunderlink://MjAyMy0wOC0yNVQxNToyOTowMC4wMDBaO05h #+end_example In the article [[https://vxlabs.com/2019/04/20/link-thunderbird-emails-from-emacs-orgmode/][Link directly to emails from Emacs Orgmode using Thunderbird and Thunderlink]] they suggest to write in your notes =message= instead of =cbthunderlink=, this way you can use something else in the future in case =cb_thunderlink= also dies as the linking system in your notes will not depend on it (at least completely). In the configuration of the =cb_thunderlink= plugin you can manage the format to copy the email link. In my case I have made one called =emacsOrgLink=, which is set to ~[[message://$cblink$][$subject$]]~ to comply with Org-mode link format. Note that the name of the link will be the subject of the email. The code above will associate the function ~org-message-thunderlink-open~ to the =message= key when =org-open-at-point= is executed on these links, and then it will replace =message= with =cbthunderlink= to pass the link to Thunderbird. Of course this part can be avoided by just letting the links in their original format (starting with =cbthunderlink=), and the function would be really simple. Once more, I chose =message= over =cbthunderlink= because =message= is built in Emacs. Nevertheless, I do not think if I stop using Thunderbird and go to Mu4e or Gnus the links would work (because of their =messageid= being different in Mu4e-Gnus VS =cb_thunderlink=). Anyway see [[https://vxlabs.com/2023/08/08/open-message/-links-with-mu4e-or-fastmail/][this recent post]] of vxlab which is similar to the one discussed above, but for Mu4e and fastmail. You can decide which format to use. The last point to highlight is the use of ~(kill-new (concat "cbthunderlink://" message-id))~. Because of limitations of the Thunderbird API, which dropped support for the =thunderbird -thunderlink = clickable feature, =cb_thunderlink= cannot directly open the emial is some systems (see documentation). In those systems where it cannot simulate the needed behavior and open the specific email directly, instead, it creates a button on the top-right corner (close to the "Display Thunderbird menu"), which once clicked will use the content of the clipboard to open the corresponding email, in case the content of the clipboard is a =cb_thunderlink= email link. This line of code copy the email link to the clipboard so we can access the desired email. Summarizing, once everything is set up. You right-click on the body of the email in Thunderbird, go to the =cb_thunderlink= menu entry (usually on the bottom), and copy the formatted link you established (=emacsOrgLink= in my case). Next, past it in Emacs. Once you need to use it, just execute =org-open-at-point= (C-c C-o), and it will open Thunderbird, but in some cases not yet the specific email. If this functionality is missing, to open the specific email just click on the =cb_thunderlink= button on the top-right region. You should see now the email. This solution is not es elegant as the use of Gnus and Notmuch, but certainly will require much less setup than those two, and time, which I don't have right now for that. If you have not the time, or would like to continue with the visual interface oriented approach that is Thunderbird in face to Gnus and Notmuch, this is the solution to have links in your notes redirecting to the related email. * Autocomplete #+BEGIN_SRC emacs-lisp ;; (use-package auto-complete ;; :ensure t ;; :init ;; (progn ;; (ac-config-default) ;; (global-auto-complete-mode t) ;; )) #+END_SRC #+begin_src emacs-lisp (use-package company :ensure t :init ;;(setq global-company-mode t) :config (setq company-tooltip-align-annotations t) (setq company-tooltip-flip-when-above t) (setq company-idle-delay 0.2) (setq company-tooltip-align-annotations t) (setq company-minimum-prefix-length 3) (setq company-format-margin-function #'company-text-icons-margin) ) (add-hook 'after-init-hook 'global-company-mode) #+end_src #+begin_src emacs-lisp (use-package company-auctex :ensure t ) #+end_src * Projectile #+begin_src emacs-lisp (use-package projectile :ensure t :init (projectile-mode +1) :bind (:map projectile-mode-map ("C-c p" . projectile-command-map))) #+end_src * Spelling #+begin_src emacs-lisp (setq ispell-program-name "aspell") (require 'ispell) #+end_src * Python #+BEGIN_SRC emacs-lisp ;; (use-package jedi ;; It need virtualenv to be installed in the pc (pip install virtualenv) ;; :ensure t ;; :init ;; (add-hook 'python-mode-hook 'jedi:setup) ;; (add-hook 'python-mode-hook 'jedi:ac-setup) ;; (add-hook 'python-mode-hook 'jedi:install-server) ;; :config ;; (progn ;; (setq jedi:environment-root "jedi") ; or any other name you like ;; (setq jedi:environment-virtualenv ;; (append python-environment-virtualenv ;; '("--python" "/usr/bin/python3"))) ;; (setq jedi:complete-on-dot t) ;; (setq jedi:get-in-function-call-delay 1) ;; )) #+END_SRC #+BEGIN_SRC emacs-lisp (defcustom python-shell-interpreter "python3" "Default Python interpreter for shell." :type 'string :group 'python) #+END_SRC #+BEGIN_SRC emacs-lisp ;; It is a package for documentation, completion, syntax check ... (use-package elpy :ensure t :config (elpy-enable) (setq python-indent-offset 4)) #+END_SRC * Latex #+BEGIN_SRC emacs-lisp (use-package tex :ensure auctex :ensure reftex :hook ((LaTeX-mode . flyspell-mode) (LaTeX-mode . visual-line-mode) (LaTeX-mode . LaTeX-math-mode) (LaTeX-mode . turn-on-reftex) ) :config (setq TeX-parse-self t) (setq TeX-auto-save t) (setq-default TeX-master nil) (setq TeX-auto-local ".auto") ;;(setq-default TeX-parse-all-errors t) (setq-default TeX-display-help t) (setq reftex-label-alist '(AMSTeX)) ;; Para que ponga \eqref (setq reftex-plug-into-AUCTeX t) (setq bibtex-dialect 'biblatex) (setq reftex-cite-format 'biblatex) (setq reftex-default-bibliography '("/home/yaidel/config/latex_bib_databases/entireLibrary.bib")) (setq LaTeX-section-hook '(LaTeX-section-heading LaTeX-section-title LaTeX-section-toc LaTeX-section-section LaTeX-section-label)) ;; (eval-after-load "tex" '(progn ;; (setq LaTeX-command (concat LaTeX-command " -shell-escape")))) ;; Don't forget to configure ;; Okular to use emacs in ;; "Configuration/Configure Okular/Editor" ;; = Editor = Emacsclient. (you should see ;; emacsclient -a emacs --no-wait +%l %(format "message" format-args)) ;; in the field "Command". ;; Enable synctex correlation. From Okular just press ;; Shift + Left click to go to the good line. ;; From Evince just press Ctrl+Shift+Left click to go to the good line. (setq TeX-source-correlate-mode t TeX-source-correlate-start-server t) (eval-after-load "tex" '(setcar (cdr (assoc 'output-pdf TeX-view-program-selection)) "Evince")) ) #+END_SRC * Spell for windows # Info tomada de: https://lists.gnu.org/archive/html/help-gnu-emacs/2014-04/msg00030.html #+BEGIN_SRC emacs-lisp ;; (if (eq system-type 'ms-dos) ;; ((add-to-list 'exec-path "E:/config/hunspell/bin/") ;; (setq ispell-program-name (locate-file "hunspell" ;; exec-path exec-suffixes 'file-executable-p)) ;; (setq ispell-local-dictionary-alist '( ;; (nil ;; "[[:alpha:]]" ;; "[^[:alpha:]]" ;; "[']" ;; t ;; ("-d" "en_US" "-p" "E:\\config\\hunspell\\share\\hunspell\\en_US.aff") ;; nil ;; iso-8859-1) ;; ("american" ;; "[[:alpha:]]" ;; "[^[:alpha:]]" ;; "[']" ;; t ;; ("-d" "en_US" "-p" "E:\\config\\hunspell\\share\\hunspell\\en_US.aff") ;; nil ;; iso-8859-1) ;; )) ;; ) ;; (setq ispell-program-name "aspell") ;; ) ;; ;; activar ispell ;;(require 'ispell) #+END_SRC * Magit #+BEGIN_SRC emacs-lisp (use-package magit :ensure t ) #+END_SRC * ORG mode specifications Some resources to which you can refer here are: - [[https://orgmode.org/manual/index.html][The Org Manual]] - [[https://blog.jethro.dev/posts/org_mode_workflow_preview/][Jethro's org-mode workflow]] - [[http://cachestocaches.com/2016/9/my-workflow-org-agenda/][Caches to Caches]] (this blog is discontinued to the best of my knowledge) - [[http://doc.norang.ca/org-mode.html][Bernt Hansen's guide]] ** Org mode :PROPERTIES: :ID: ebdfd897-7542-44e6-8413-632b41e7fb32 :END: Setting the name of the file where all the captured notes are going to. #+begin_src emacs-lisp (setq organizer-file "20230105T175954--organizer__personal.org") #+end_src Set =C-c o= to edit the =organizer= file: #+BEGIN_SRC emacs-lisp (defun organizer-visit () (interactive) (find-file (concat "/media/Datos/notes/" organizer-file))) (global-set-key (kbd "C-c o") 'organizer-visit) #+END_SRC The =org-agenda-files= configuration has been written in the section [[*Adding _project files to the agenda][Adding _project files to the agenda]], because it uses [[*Denote][Denote's]] tags in the file name to detect the project files and add them to the list. #+begin_src emacs-lisp (use-package org :ensure t :hook (org-mode . flyspell-mode) (org-mode . visual-line-mode) (org-mode . org-indent-mode) :config ;; (setq org-adapt-indentation nil) ;; set the identation method in ORG mode (setq org-clock-persist 'history) ;; Clocking projects time settings to save clocking history throughout sessions (org-clock-persistence-insinuate) (setq org-clock-idle-time 10) (setq org-clock-out-remove-zero-time-clocks t) ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration (setq calendar-week-start-day 1) ;; ;; Tasks and Todos (setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WORKING(w)" "DELEGATED(g)" "|" "DONE(d)" "CANCELED(x)") (sequence "COMPUTE(c)" "COMPUTING(p)" "|" "FINISHED(f)" "UNFINISHED(u)"))) (setq org-todo-keyword-faces (quote (("TODO" :background "IndianRed1" :foreground "black" :weight bold) ("NEXT" :background "sky blue" :foreground "black" :weight bold) ("WORKING" :background "lemon chiffon" :foreground "black" :weight bold) ("COMPUTING" :background "lavender" :foreground "black" :weight bold) ("DONE" :background "DarkOliveGreen2" :foreground "black" :weight bold) ("CANCELED" :background "DarkOliveGreen2" :foreground "black" :weight bold) ("DELEGATED" :background "aquamarine2" :foreground "black" :weight bold)))) (setq org-tag-alist '(("@project" . ?p) ("@someday" . ?s) ("@pyrene" . ?y) ("@curta" . ?c) ("@irene" . ?i))) ;; ;; TODO states trigers (setq org-todo-state-tags-triggers (quote ((done ("@pyrene") ("@curta") ("@irene") ("@project") ("@someday"))))) ;; ;; Capture (setq org-directory "/media/Datos/notes/") (setq org-default-notes-file (concat org-directory organizer-file)) (setq org-health-tracking-file (concat org-directory "20230815T112721--health-tracking__health.org")) (global-set-key (kbd "C-c c") 'org-capture) ;; use C-c c to start capture mode ;; capture templates for: TODO tasks, Notes, appointments, meetings (setq org-templates-location-var (concat org-directory organizer-file)) (setq org-capture-templates '(("t" "Todo" entry (file+headline org-templates-location-var "Inbox") "* TODO %? \nCaptured on %U") ("h" "Health Tracking" entry (file+headline org-health-tracking-file "Daily data") "* %t \n:PROPERTIES:\n:barras: %?\n:pararelas: \n:planchas: \n:abdominales: \n:dificultad: \n:ánimo: \n:tiempo: \n:sueño: \n:ayuno: \n:caminar: \n:END:") ("n" "Read later / take a note" entry (file+headline org-templates-location-var "Inbox") "* Note from %a\nCaptured on: %U\n\n*Highlighted region*: %i\n\n%?") ("c" "Coding" entry (file+headline org-templates-location-var "Inbox") "* TODO %? \nCaptured on %U\n*File*: [[file+emacs:%F]]\n*Highlighted region*:\n#+begin_src\n%i\n#+end_src\n\n"))) ;; Refile ;; Targets include this file and any file contributing to the agenda - up to 9 levels deep ;; C-c C-w for refile (setq org-refile-targets (quote ((nil :maxlevel . 3) (org-agenda-files :maxlevel . 3)))) ;; ;; Agenda customization ;; (global-set-key (kbd "C-c a") 'org-agenda) ;; ;; Format of the columns in the agenda view (setq org-columns-default-format-for-agenda "%65item(Task) %Effort(Effort){:} %clocksum_t(Today) %clocksum(Total)") ;; Format the habits tracker in the agenda buffer (setq org-habit-following-days 1) (setq org-habit-graph-column 80) (setq org-agenda-custom-commands '(("x" "My Agenda" ((agenda "" ((org-agenda-overriding-header "Today's Schedule:") (org-agenda-span 'day) (org-agenda-ndays 1) (org-agenda-start-on-weekday nil) (org-agenda-start-day "+0d") (org-agenda-sorting-strategy (quote (time-up deadline-down priority-down))))) (tags-todo "-@project/+WORKING" ((org-agenda-overriding-header "Tasks in progress") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))))) (tags-todo "-@project/+NEXT" ((org-agenda-overriding-header "Next tasks") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))) (org-agenda-max-entries 5))) (tags-todo "-@project/+TODO" ((org-agenda-overriding-header "TODOs") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))) (org-agenda-max-entries 5))) ;; (agenda "" ;; ((org-agenda-overriding-header "The Week in a Glance:") ;; (org-agenda-sorting-strategy ;; (quote ;; (time-up deadline-down priority-down))))) (tags "+@capture-@excludeFromAgenda" ((org-agenda-overriding-header "Items to refile") ;;(org-tags-match-list-sublevels nil) (org-agenda-sorting-strategy (quote (priority-down time-down))))) (org-agenda-list-stuck-projects) (tags "CLOSED<=\"<-1m>\"" ((org-agenda-overriding-header "Items to archive (older than a month)") (org-agenda-span (quote month)))))) ("c" "Computations" ((tags-todo "TODO=\"COMPUTING\"+@curta" ((org-agenda-overriding-header "Computations Curta") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))))) (tags-todo "TODO=\"COMPUTING\"+@pyrene" ((org-agenda-overriding-header "Computations Pyrene") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))))) (tags-todo "TODO=\"COMPUTING\"+@irene" ((org-agenda-overriding-header "Computations TGCC") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))))) )) ("p" "Projects" ((tags-todo "+@project-@someday/-DELEGATED-DONE-CANCELED" ((org-agenda-overriding-header "Working on:") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))))) (tags-todo "+@project+@someday/-DELEGATED-DONE-CANCELED" ((org-agenda-overriding-header "Maybe/Someday Projects:") (org-agenda-sorting-strategy (quote (priority-down deadline-down effort-down))))) (org-agenda-list-stuck-projects) )) )) (setq org-stuck-projects '("+@project/-DONE-CANCELED-DELEGATED" ;; entries considered as projects ("NEXT" "WORKING") ;; if none of these are present in the subtree, the project is stuck ("@someday") ;; list of tags identifying non-stuck projects "")) ;; arbitrary regular expression matching non-stuck projects ;; as the @project tag defines what is a project, I do not want all the sub-trees are marked also as projects ;; I want to manually set what are the projects (setq org-tags-exclude-from-inheritance '("@project" "project" "blog" "@excludeFromAgenda")) ) #+end_src Furthermore, to automatically set the values displayed in the agenda identifying the file from where the task is being pulled from to the "humanized" name of the file in the file-system, Boris Buliga proposed the following configuration in [[https://d12frosted.io/posts/2020-06-24-task-management-with-roam-vol2.html][this blog post]]. Nevertheless, after some time using it, I removed it from my configuration. A simpler solution is just to specify the =#+category:= value in the heading of the =org= file being added to the agenda, and that value will be the one appearing in the agenda dispatcher identifying that specific file. This solution is the implemented in =org-mode= by default, and therefore the more straightforward. It has to be taken into account that a field of 12 characters is designed to show the categories, so =#+category= values longer than 10 characters should not be used to maintain beauty and order in the agenda dispatcher. See also https://orgmode.org/manual/Categories.html for more. #+begin_src example (defun vulpea-buffer-prop-get (name) "Get a buffer property called NAME as a string." (org-with-point-at 1 (when (re-search-forward (concat "^#\\+" name ": \\(.*\\)") (point-max) t) (buffer-substring-no-properties (match-beginning 1) (match-end 1))))) (defun vulpea-agenda-category (&optional len) (let* ((file-name (when buffer-file-name (file-name-sans-extension (file-name-nondirectory buffer-file-name)))) (title (vulpea-buffer-prop-get "title")) (category (org-get-category)) (result (or (if (and title (string-equal category file-name)) title category) ""))) (if (numberp len) (s-truncate len (s-pad-right len " " result)) result))) (setq org-agenda-prefix-format '((agenda . "%(vulpea-agenda-category 12)%?-12t%s ") (todo . "%(vulpea-agenda-category 12) ") (tags . "%(vulpea-agenda-category 12) ") (search . "%(vulpea-agenda-category 12) "))) #+end_src Add the habit module to org. #+begin_src emacs-lisp ;; ;; Habits module enabled ;; (add-to-list 'org-modules 'habit) (require 'org-habit) #+end_src Remove tags from the right columns of the agenda dispatcher. #+begin_src emacs-lisp (setq org-agenda-remove-tags t) #+end_src Do not start the Agenda on Mondays, but the day you are on #+begin_src emacs-lisp (setq org-agenda-start-on-weekday nil) #+end_src ** Activate Babel languages (gnuplot, python, etc) To execute certain languages inside an org buffer and to use the data contained in it (ex. tables), you need to enable the language. See the documentation [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.html][in the case of gnuplot]] and [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html][in the case of python]] for more information. #+begin_src emacs-lisp ;; active Babel languages (org-babel-do-load-languages 'org-babel-load-languages '((gnuplot . t) (python . t))) #+end_src ** Org-bullets #+BEGIN_SRC emacs-lisp (use-package org-bullets :ensure t :after (org) :hook (org-mode . (lambda () (org-bullets-mode 1))) :config (setq org-log-done 'time) (setq org-file-apps-gnu ;; esto es para que al exportar en org-mode se abra correctamente el PDF (append '((t . "setsid -w xdg-open %s")) org-file-apps-gnu)) :bind ("C-c x ." . 'org-time-stamp-inactive) ) #+END_SRC ** Visual tweaks ** Org Tempo For Structure Templates [[https://orgmode.org/manual/Structure-Templates.html][(see Org webpage]]) #+begin_src emacs-lisp (require 'org-tempo) (add-to-list 'org-structure-template-alist '("sh" . "src shell")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (add-to-list 'org-structure-template-alist '("py" . "src python")) #+end_src ** Org Export Markdown Enable Markdown export back-end (see [[https://orgmode.org/manual/Exporting.html][Org-export manual]]) #+begin_src emacs-lisp (require 'ox-md) #+end_src ** Org Export Latex #+begin_src emacs-lisp (require 'ox-latex) ;; set the sequence for the compilation (setq org-latex-pdf-process '("pdflatex -interaction nonstopmode -output-directory %o %f" "bibtex %b" "pdflatex -interaction nonstopmode -output-directory %o %f" "pdflatex -interaction nonstopmode -output-directory %o %f")) ;; stop org adding hypersetup{author..} to latex export (setq org-latex-with-hyperref nil) ;; (setq org-latex-prefer-user-labels t) ;; deleted unwanted file extensions after latexMK (setq org-latex-logfiles-extensions (quote ("lof" "lot" "tex~" "aux" "idx" "log" "out" "toc" "nav" "snm" "vrb" "dvi" "fdb_latexmk" "blg" "brf" "fls" "entoc" "ps" "spl" "bbl" "xmpi" "run.xml" "bcf" "acn" "acr" "alg" "glg" "gls" "ist"))) (unless (boundp 'org-latex-classes) (setq org-latex-classes nil)) #+end_src * Org-cite and citations handling To configure the citations within Org, we have its Org-cite functionality. More information about this functionality can be found in the follwoing sources: - [[https://orgmode.org/manual/Citation-handling.html#Citation-handling][Citation handling (The Org Manual)]] - [[https://kristofferbalintona.me/posts/202206141852/][Citations in Org-mode (by Kristoffer Balintona)]] - [[https://blog.tecosaur.com/tmio/2021-07-31-citations.html#fn.3][Introducing citations (by Tecosaur)]] To use Org-cite, the first step is to load the processor you are interested in to export your bibliography. See [[https://orgmode.org/manual/Citation-export-processors.html][available processors here]]. #+begin_src emacs-lisp (require 'oc-basic) (require 'oc-biblatex) (require 'oc-csl) #+end_src Then, either you specify in a per file basis the procesor to use and the address of the bib file, or you do it globally here at the configuration file. The first option would be as follows: #+begin_example ,#+bibliography: /home/yaidel/config/latex_bib_databases/entireLibrary.bib ,#+cite_export: biblatex Text with cites goes here. ,#+print_bibliography: #+end_example Nevertheless, I have chosen the second option, globally specifying the processors for different types of files, and also the entireLibrary.bib resource. Note that =#+print_bibliography:= has to be entered manually where you whant the bibliography to appear. #+begin_src emacs-lisp (setq org-cite-global-bibliography '("/home/yaidel/config/latex_bib_databases/entireLibrary.bib")) (setq org-cite-export-processors '((md . (csl "chicago-fullnote-bibliography.csl")) ; Footnote reliant (latex biblatex) ; LaTeX (odt . (csl "vancouver-superscript.csl")) ; Footnote reliant (t basic))) (setq org-cite-csl-styles-dir "/home/yaidel/config/ZoteroData/styles") (use-package citeproc :ensure t) #+end_src For LaTeX it is possible to specify other options and customizations, and if it is true that there may be a way to do so exclusively using Org-cite, I have come to find the use of =#+LATEX_HEADER:= to add LaTeX options. I have created an Skeleton in [[*Org mode and note taking][Org mode and note taking]] section which is called =skeleton-org-export-latex-options= to handle automatically the necessary options to export to as I want. * Calendar and Diary The following option displays by default the dates which are holidays in a different face in the calendar. This can be achieved also pressing =x= in the calendar buffer. To remove this behavior use the key =u= in the calendar buffer. For more information see section "28.6 Holidays" in the Emacs Manual. #+begin_src emacs-lisp (setq calendar-mark-holidays-flag t) #+end_src * Denote *Denote Tips* - When using =denote-open-or-create=, if you type-in the name of the note to find that it does not exists, and you want to create it, after hitting ENTER you'll be redirected to the echo area to enter the name of the note. *Hitting =M-p= will bring back the name you entered previously* #+begin_src emacs-lisp (use-package denote :ensure t :demand t :config ;; ;; General key bindings (setq denote-directory (expand-file-name "/media/Datos/notes")) (setq denote-known-keywords '("emacs" "project")) (setq denote-infer-keywords t) (setq denote-sort-keywords t) ;; ;; Tweaking the frontmatter (setq denote-org-front-matter "#+title: %s\n#+date: %s\n#+filetags: %s\n#+identifier: %s\n#+author: yaidel\n#+startup: showall\n\n") :bind ("C-c n f" . denote-open-or-create) ("C-c n n" . denote) ("C-c n l" . denote-link-or-create) ("C-c n B" . denote-find-link) ("C-c n b" . denote-backlinks) ) #+end_src ** Adding _project files to the agenda First we set the =org-agenda-files= to point to the notes folder, so it shoud use the =org-agenda-file-regexp= default value to load all the files inside it which end by =.org=. The next step is then to modify the =org-agenda-file-regexp= variable to load all the files containig the keyword =_project=. This means that all the project files will be added to the =org-agenda-file= variable, which is almost perfect, as those files are the ones which should have TODOs. Note that the =list= function is important in setting =org-agenda-files= with =setq=, as it need to be a list, and not a string. Also, if instead of =setq= one uses =add-to-list=, it is ok to just write the string. #+begin_src emacs-lisp (setq org-agenda-file-regexp "\\`[^.].*_project.*\\.org\\'") (setq org-agenda-files (list "/media/Datos/notes/" (concat org-directory organizer-file))) #+end_src But the addition of the project files to the agenda will happen when Emacs loads, what if we added some other projects during this section and what to have them in the agenda? *The following functions need some more refinement* The problem with the function adding the new file tagged as =_project= to the list =org-agenda-files= is that it is an =after-save-hook=. This means that it will be executed each time you save a file. As consequence, if you opened an existing file which is a project you have already being working on, make some modifications, and save it, you will be saving a file which has the =_project= keyword. As consequence, it will be listed twice in the =org-agenda-files= variable, and its entries will appear duplicate in the agenda dispatcher. A solution to this problem would be to check if the file being added already exists in the =org-agenda-files= list, and add it only if it is not. Unfortunately, at the moment I do not know how to do that en Elisp. The solution is to comment the function and add any new file in the session to the =org-agenda-files= by using the =org-agenda-file-to-front= (bind to =C-c [=). In a new session the new project will be added automatically due to the above declaration of =org-agenda-file-regexp=. Additionally, Protesilaos also provided a function which deletes the file from the =org-agenda-files= variable when the tag =project= is removed. Nevertheless, it has a problem: when the _project keyword is removed (by using =denote-keywords-remove=), then the file is no longer named as it is specified in the =org-agenda-files= variable, because the =_project= part of the name was removed together with the keyword. For that reason this function will never succeed in removing the file from the list. Anyhow, the files will be deleted once emacs is closed and reopened, due to the definition of =org-agenda-files= and =org-agenda-file-regexp= (see above). #+begin_src emacs-lisp ;; (defvar my-denote-to-agenda-regexp "_project" ;; "Denote file names that are added to the agenda. ;; See `my-denote-add-to-agenda'.") ;; ;; (defun my-denote-add-to-agenda () ;; "Add current file to the `org-agenda-files', if needed. ;; The file's name must match the `my-denote-to-agenda-regexp'. ;; ;; Add this to the `after-save-hook' or call it interactively." ;; (interactive) ;; (when-let* ((file (buffer-file-name)) ;; ((denote-file-is-note-p file)) ;; ((string-match-p my-denote-to-agenda-regexp (buffer-file-name)))) ;; (add-to-list 'org-agenda-files file))) ;; ;; (add-hook 'after-save-hook #'my-denote-add-to-agenda) #+end_src #+begin_src emacs-lisp ;; (defun my-denote-remove-from-agenda () ;; "Remove current file from the `org-agenda-files'. ;; See `my-denote-add-to-agenda' for how to add files to the Org ;; agenda." ;; (interactive) ;; (when-let* ((file (buffer-file-name)) ;; ((string-match-p my-denote-to-agenda-regexp (buffer-file-name)))) ;; (setq org-agenda-files (delete file org-agenda-files)))) ;; (add-hook 'after-save-hook #'my-denote-remove-from-agenda) #+end_src Furthermore, to those using Org-roam, https://d12frosted.io/ has a perfect solution to add files with TODOs to the =org-agenda-files= variable. In fact, that solution is much better than adding all files with the =_project= keyword in their name, but it is not possible to implement while using Denote. Because Denote do not uses databases, the search for all the files containing =:project:= as keyword in the org heading is not possible. ** Journal entries Define a function to handle the creation of the journal entry: #+begin_src emacs-lisp (defun my-denote-journal () "Create an entry tagged 'journal' with the date as its title. If a journal for the current day exists, visit it. If multiple entries exist, prompt with completion for a choice between them. Else create a new file." (interactive) (let* ((today (format-time-string "%A %e %B %Y")) (string (denote-sluggify today)) (files (denote-directory-files-matching-regexp string))) (cond ((> (length files) 1) (find-file (completing-read "Select file: " files nil :require-match))) (files (find-file (car files))) (t (denote today '("journal")))))) #+end_src And add a key binding for it #+begin_src emacs-lisp (global-set-key (kbd "C-c n j") 'my-denote-journal) #+end_src Finally, define a function and a keybinding to handle the creation of weekly review journal entries: #+begin_src emacs-lisp (defun my-denote-weekly-review () "Create an entry tagged 'week' with the date as its title. If a week-note for the current week exists, visit it. If multiple entries exist, prompt with completion for a choice between them. Else create a new file." (interactive) (let* ((today (format-time-string "Weekly review for week number %W of %Y")) (string (denote-sluggify today)) (files (denote-directory-files-matching-regexp string))) (cond ((> (length files) 1) (find-file (completing-read "Select file: " files nil :require-match))) (files (find-file (car files))) (t (denote today '("journal")))))) #+end_src And add a key binding for it #+begin_src emacs-lisp (global-set-key (kbd "C-c n w") 'my-denote-weekly-review) #+end_src * ERC Initial configuration of the user and chats to connect to. #+begin_src emacs-lisp (setq erc-server "irc.libera.chat" erc-port "6697" erc-nick "yaidel" erc-user-full-name "yaidel" erc-track-shorten-start 8 erc-autojoin-channels-alist '(("irc.libera.chat" . "#emacs")) erc-kill-buffer-on-part t erc-auto-query 'bury) #+end_src Configuration of what to show or not on the cannels and the changes in status of them and thir participants #+begin_src emacs-lisp (setq ;;erc-track-exclude '("#emacs") erc-track-exclude-types '("JOIN" "NICK" "QUIT" "MODE" "AWAY") erc-hide-list '("JOIN" "NICK" "QUIT" "MODE" "AWAY") erc-track-exclude-server-buffer t erc-interpret-mirc-color t) #+end_src This causes ERC to connect to the Libera.Chat network upon hitting C-c f #+begin_src emacs-lisp (global-set-key "\C-cf" (lambda () (interactive) (erc-tls :server "irc.libera.chat" :port "6697" :nick "yaidel"))) #+end_src Facilitating the automatic loggin to the IRC server by using auth-source library. #+begin_src emacs-lisp (setq erc-prompt-for-password nil) (setq erc-prompt-for-nickserv-password nil) (setq auth-sources '(password-store)) #+end_src ** password-store #+begin_src emacs-lisp (use-package password-store :ensure t) #+end_src * Markdown mode #+begin_src emacs-lisp (use-package markdown-mode :ensure t :mode ("README\\.md\\'" . gfm-mode) :init (setq markdown-command "multimarkdown") :hook (markdown-mode . flyspell-mode) (markdown-mode . visual-line-mode) ) #+end_src * Skeletons Skeletons are a functionality available in Emacs Lisp which serves as shorthands, kind of what Yasnippets do, but it already incorporated into Emacs and no other package is needed. The syntax they follow can be see at [[https://www.gnu.org/software/emacs/manual/html_node/autotype/Skeleton-Language.html][the manual page]]. Some further examples and explainations can also be found at the Emacswiki [[https://www.emacswiki.org/emacs/SkeletonMode][SkeletonMode page]]. ** Org mode and note taking For more configuration of the LaTex export options, see: - The [[https://orgmode.org/manual/LaTeX-Export.html][LaTeX Export]] section of the Org-mode manual. #+begin_src emacs-lisp (define-skeleton skeleton-org-export-latex-options "Options inserted into an org file to export it to LaTex or PDF." nil "#+LATEX_CLASS_OPTIONS: [12pt]\n" "#+LATEX_HEADER: \\usepackage[style=numeric-comp, sorting=none, maxbibnames=3, minbibnames=3, maxcitenames=1, mincitenames=1, isbn=false, url=false, doi=false, eprint=false, related=false]{biblatex}\n" "#+LATEX_HEADER: \\renewbibmacro{in:}{}\n" "#+OPTIONS: \<:nil c:nil todo:nil H:5\n\n" _ "\n\n* References\n" ":PROPERTIES:\n" ":UNNUMBERED: t\n" ":END:\n" "#+print_bibliography: :heading none" ) #+end_src Project Meaningful Planning #+begin_src emacs-lisp (define-skeleton skeleton-project-body "Insert the body of the Project Planning, acording to the Getting Things Done principles" nil "* NAME OF THE PROJECT"_ " :@project:\n" "\n" "Think carefully, after the Purpose and Principles section completion, if the project is really worth our\n" "effort and time.\n" "\n" "- /Resources/: Me\n" "\n" "** Purpose and Principles of the project\n" "\n" "The first step when starting a project is to clearly define *why* are we going to spend *our time* in it. This\n" "way we can see why is it important, and why will its outcome be important to us. Also knowing the project's\n" "standards and quality requirements will help us. We do not need to put so much effort in something which has\n" "low standards, as a small tutorial for a friend, for example...some picture would suffice there.\n" "\n" "- /Why this project needs to be produced (its purpose)?/: \n" "- /What are the standards and quality requirements for the project (its principles)/: \n" "\n" "** Outcome visioning\n" "\n" "What will result from a successful outcome? What will it be like when the project is out in the world? It is\n" "easier to visualize something and head towards it, than going without direction. This will help to know what\n" "it might take to get there.\n" "\n" "- /What the end product will ideally look like/: \n" "- /How I will ideally feel afterwards/: \n" "- /How others will ideally respond/: \n" "- /What else will result from the completion of the project/: \n" "\n" "** Ideas dump\n" "\n" "Write *ever* idea that comes to your mind related to this project. It may be tasks to do, sub-projects to\n" "derive from it, relations with other projects, strategies to follow... *Everything*. Aim for *quantity over\n" "quality*. Resist organization, correction and analysis. Those are tasks to develop after all the ideas have\n" "been written down.\n" "\n" "- Ideas ...\n" "\n" "** To do list\n" "\n" "After the [[*Ideas sump][Ideas dump]] process, and in its organization process, some tasks will need to be done to achieve the\n" "final outcome of the project. This is the place to write them. Including the project in the\n" "=org-agenda-files=, and adding =TODO= and =NEXT= items, it is really easy to keep track of its progress\n" "together with all others at the same time, due to the =Org Agenda= exceptional capacities in doing so. If more\n" "information on this is needed, it can be found at [[file:/media/Datos/notes/20230105T120307--working-in-org-mode__config_emacs.org::*Agenda files][this tips note]] or at the specific section of the Emacs\n" "configuration file ([[*Adding _project files to the agenda][Adding _project files to the agenda]]).\n" "\n" ) #+end_src The following Skeletons the column view I use to identify the time estimated and expended in the projects and tasks. More information can be found at the [[https://orgmode.org/manual/Column-View.html][Column View]] section of the Org-mode manual, but the most basic ones are given in the next table: | Keybinding | Function | Description | |-------------+-------------------+--------------------------------------------------------------| | C-c C-x e | org-set-effort | Set the effort property of the current entry. | | C-c C-x C-c | org-columns | Turn on column view on an Org mode file. | | C-c C-c | org-ctrl-c-ctrl-c | If column view is active, in agenda or org buffers, quit it. | #+begin_src emacs-lisp (define-skeleton skeleton-column-project-times "Insert a global column definition to show that time estimated VS the real time expended in a project." nil "#+columns: %65item(Task) %Effort(Effort){:} %clocksum_t(Today) %clocksum(Total)" ) #+end_src ** LaTeX Article skeleton #+begin_src emacs-lisp (define-skeleton skeleton-LaTeX-article "The skeleton of an article in LaTeX" nil "\\documentclass{article}\n" "\\usepackage{/home/yaidel/config/dotFiles/latex_styles/article_sty}\n" "\\addbibresource{/home/yaidel/config/latex_bib_databases/entireLibrary.bib}\n" "\n" "\\title{}\n" "\\author{Yaidel TOLEDO GONZALEZ}\n" "\\date{\\today}\n" "\n" "\\begin{document}\n" "\\maketitle\n" "\\tableofcontents\n" "\n" _ "\n\n" "\\printbibliography\n" "\\end{document}\n" ) #+end_src ** Hugo and blogging Heading for Markdown Hugo post using the Yugo theme #+begin_src emacs-lisp (define-skeleton skeleton-md-Yugo-heading-hugo-post "Heading for a new post in Hugo using Markdown and the Yugo theme" nil "---\n" "title: \n" _ "author:\n" " post_name: yaidel\n" " mdata_name: yaidel\n" "date: \"2023-01-01\"\n" "lastmod: \"2023-01-01\"\n" "categories: [""]\n" "tags: [""]\n" "draft: true\n" "description: \n" "---\n" ) #+end_src #+begin_src emacs-lisp (define-skeleton skeleton-md-PaperMod-heading-hugo-post "Heading for a new post in Hugo using Markdown and the PaperMod theme" nil "---\n" "title: \"" _ "\"\n" "date: 2023-04-10\n" "# weight: 1 # pin the post to the begining no matter the date\n" "# aliases: [\"/alias-to-post\"]\n" "tags: [\"tag1\"]\n" "categories: [\"cat1\"]\n" "author: [\"yaidel\"]\n" "showToc: false\n" "TocOpen: false\n" "draft: true\n" "hidemeta: false\n" "math: false\n" "description: \"Desc Text.\"\n" "cover:\n" " image: \"\"\n" " alt: \"\"\n" " caption: \"\"\n" " relative: true # when using page bundles set this to true\n" " hidden: false # only hide on current single page\n" "---\n" ) #+end_src Figures polaroid like in a blog post #+begin_src emacs-lisp (define-skeleton skeleton-Hugo-fig-polaroid "Hugo shortcode for the images showed as Polaroid" nil "{{< img class=\"polaroidImage\" width=\"50%\" src=\"image.png\" caption=\"Caption\" link=\"https://poview.org\" alt=\"Alternative text\" mouse=\"Mouse over\" >}}\n" ) #+end_src * GNUPlot mode #+begin_src emacs-lisp (use-package gnuplot-mode :ensure t) #+end_src #+begin_src emacs-lisp (use-package gnuplot :ensure t) #+end_src * Go-lang mode #+begin_src emacs-lisp (use-package go-mode :ensure t) #+end_src * Packages I want to try and probably use - PDFTools: https://github.com/vedang/pdf-tools - Org-noter: https://github.com/weirdNox/org-noter - Org-Download: https://github.com/abo-abo/org-download - Org-Protocol: https://orgmode.org/worg/org-contrib/org-protocol.html - Eglot: https://github.com/joaotavora/eglot - It's like an auto-completion and helper major mode.