-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '5d39fd896474aaa612d03ce1ae7991258cae45c5' as 'emacs-cus…
…tom-templates'
- Loading branch information
Showing
29 changed files
with
580 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/emacs | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=emacs | ||
|
||
### Emacs ### | ||
# -*- mode: gitignore; -*- | ||
*~ | ||
\#*\# | ||
/.emacs.desktop | ||
/.emacs.desktop.lock | ||
*.elc | ||
auto-save-list | ||
tramp | ||
.\#* | ||
|
||
# Org-mode | ||
.org-id-locations | ||
*_archive | ||
|
||
# flymake-mode | ||
*_flymake.* | ||
|
||
# eshell files | ||
/eshell/history | ||
/eshell/lastdir | ||
|
||
# elpa packages | ||
/elpa/ | ||
|
||
# reftex files | ||
*.rel | ||
|
||
# AUCTeX auto folder | ||
/auto/ | ||
|
||
# cask packages | ||
.cask/ | ||
dist/ | ||
|
||
# Flycheck | ||
flycheck_*.el | ||
|
||
# server auth directory | ||
/server/ | ||
|
||
# projectiles files | ||
.projectile | ||
|
||
# directory configuration | ||
.dir-locals.el | ||
|
||
# network security | ||
/network-security.data | ||
|
||
|
||
# End of https://www.toptal.com/developers/gitignore/api/emacs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
include helper.mk | ||
include init.mk | ||
|
||
SETUP_CONFIG_FILE=config.org | ||
PROJECT_NAME=emacs-custom-templates | ||
|
||
all: emacs-run-tangle create-symbolic-link | ||
|
||
##@ Acciones | ||
|
||
# - evaluará todos los bloques de código de un archivo .org (Org Mode) y generará un código fuente .el (Elisp) | ||
# - cargar el código fuente .el en la configuración de .spacemacs | ||
emacs-run-tangle: ## generar archivo de configuración en ~/.emacs.d | ||
emacs --batch \ | ||
--eval "(require 'org)" \ | ||
--eval '(org-babel-tangle-file "${SETUP_CONFIG_FILE}")' | ||
|
||
create-symbolic-link: ## generar enlace simbólico de los templates en ~/org-files | ||
mkdir --verbose --parents ~/org-files/ \ | ||
&& ln --verbose --symbolic ${PWD}/templates ~/org-files/ | ||
|
||
# TODO: notificar la creación del makefile oculto | ||
# TODO: evaluar necesidad copiar la configuración de .dir-locals.el | ||
create-new-project: ## crear estructura de directorios de templates en un directorio | ||
read -p "Ingrese la ruta del proyecto a crear/configurar: " NEW_PROJECT_PATH; \ | ||
mkdir --verbose --parents $${NEW_PROJECT_PATH}; \ | ||
cp --verbose init.mk $${NEW_PROJECT_PATH}/.$(PROJECT_NAME).mk ; \ | ||
make --no-print-directory --directory=$${NEW_PROJECT_PATH} --file=.$(PROJECT_NAME).mk init | ||
|
||
.PHONY: all emacs-run-tangle create-symbolic-link create-new-project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
* Descripción de la estructura de directorio | ||
- ~config.org~ describe los bloques de configuración de emacs en ~elisp~ | ||
- ~examples.org~ ejemplos de configuración | ||
- ~templates/~ contiene las plantillas usadas por ~org-capture-template~ (habrá un enlace simbólico en ~~/org-files~) | ||
- ~pages/~ contiene documentación propia reutilizando las plantillas de ~templates/~ | ||
* Modo de uso de mi configuración | ||
** Configuración casi automática | ||
#+BEGIN_QUOTE | ||
al ejecutar en la terminal de linux el comando ~make~ (en la raíz del proyecto) | ||
1. ejecutará el comando ~org-babel-tangle~ en emacs | ||
2. creará un enlace simbólico del directorio ~templates/~ en ~~/org-files~ (otros proyectos compartirán los mismos templates) | ||
#+END_QUOTE | ||
|
||
#+BEGIN_QUOTE | ||
es "casi" automática, porque debemos agregar una linea en el archivo ~~/.spacemacs~ | ||
#+END_QUOTE | ||
** Comando org-babel-tangle | ||
- evalúa todos los *bloques de código* y los inserta en el archivo especificado según el parámetro ~:tangle nombre-archivo~ | ||
- atajos para ejecutar el comando ~org-babel-tangle~ | ||
- ~, b t~ (evil mode) | ||
- ~C-c C-v t~ | ||
- ~M-x org-babel-tangle~ | ||
|
||
#+BEGIN_QUOTE | ||
la ejecución del comando ~org-babel-tangle~ se encuentra automatizada en el archivo ~config.org~ y en el Makefile | ||
#+END_QUOTE | ||
** Cargar configuración en Spacemacs | ||
*** Atajos | ||
- el atajo ~SPC f e R~ recarga la configuración de Spacemacs | ||
- el atajo ~SPC f e d~ para editar el archivo de configuración ~.spacemacs~ | ||
|
||
#+BEGIN_QUOTE | ||
la ejecución del atajo ~SPC f e R~ asociada a ~dotspacemacs/sync-configuration-layers~ | ||
ya se encuentra automatizada en el archivo ~config.org~ y en el Makefile | ||
#+END_QUOTE | ||
*** Configuración | ||
#+BEGIN_SRC elisp :tangle no | ||
;; - en el archivo ~/.spacemacs agregar dentro de dotspacemacs/user-config | ||
;; - myconfig.el contiene mi configuración, la cargamos luego de que se cargó paquete org mode | ||
(with-eval-after-load 'org | ||
(load-file "~/.emacs.d/myconfig.el")) | ||
#+END_SRC | ||
** Argumentos del archivo de configuración | ||
*** Propiedad header-args | ||
- necesaria para cambiar las propiedades a todos los *bloques de código* | ||
- con ~header-args:elisp~ indicamos que evalúe los *bloques de código* que utilicen el lenguaje *elisp* | ||
- el atajo ~C-c C-c~ aplica los nuevos cambios en los parámetros que hagamos en ~:results~, ~:tangle~, ~:comments~, .. | ||
*** Parámetro :tangle | ||
- indicamos dónde escribir el contenido evaluado de los *bloques de código* | ||
- Ej. ~:tangle ruta/nombre.el~ | ||
*** Parámetro :comments | ||
- asociará a cada *bloque de código* insertado en ~config.el~ con un comentario (con la linea anterior a éste en éste archivo .org) | ||
- ej. ~:comments yes~ | ||
* Shortcuts | ||
** Emacs | ||
| | evil mode | org mode command | description | | ||
|--------------------------+-----------+----------------------+-----------------------------------------------------------------------| | ||
| | SPC a o t | org-todo-list | mostrar listado de las tareas de la agenda | | ||
| | SPC a o o | org-agenda | mostrar agenda de actividades/tareas | | ||
| C-c C-d | , d d | org-deadline | fijar fecha límite/final de entrega | | ||
| C-c C-s | , d s | org-schedule | fijar fecha planificada de inicio/comienzo | | ||
|--------------------------+-----------+----------------------+-----------------------------------------------------------------------| | ||
| C-c C-t | , T T | org-todo | elegir un estado de una tarea (TODO,DOING,DONE,..) | | ||
| C-c , | , p | org-priority | elegir una prioridad (#A Alta, #B Normal, #C Baja) | | ||
| | | | | | ||
| M-ArrowDown, M-ArrowUp | | | cambiar la prioridad | | ||
| M-ArrowLeft M-ArrowRight | | | cambiar el estado de una tarea | | ||
|--------------------------+-----------+----------------------+-----------------------------------------------------------------------| | ||
| | , i p | org-set-property | agregar/modificar una propiedad | | ||
| | , i t | org-set-tags-command | | | ||
|--------------------------+-----------+----------------------+-----------------------------------------------------------------------| | ||
| C-h v | SPC h d v | describe-variable | (Ej. org-todo-keywords, org-priority-faces, ..) | | ||
| C-h a | SPC h d a | apropos-command | (Ej. org-agenda) | | ||
| | | org-mode-restart | Para visualizar cambios recientes aplicados | | ||
|--------------------------+-----------+----------------------+-----------------------------------------------------------------------| | ||
| | , s s | org-sparse-tree | Filtrar subtareas por tags, su estado TODO, propiedades | | ||
|--------------------------+-----------+----------------------+-----------------------------------------------------------------------| | ||
| | C-c $ | org-archive-location | Archiva un árbol de tareas finalizadas hace mucho como ~.org_archive~ | | ||
** Org Agenda | ||
| m | buscar tareas por tags | | ||
| t | listar todas las tareas | | ||
| n | mostrar agenda + listar todas las tareas | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#+PROPERTY: header-args:elisp :comments yes :results silent :tangle ~/.emacs.d/myconfig.el | ||
* Intro | ||
#+BEGIN_SRC elisp :tangle no | ||
;; para aplicar los cambios de configuración, | ||
;; ejecutar éste bloque con el atajo C-c C-c | ||
(org-babel-tangle) | ||
(dotspacemacs/sync-configuration-layers) | ||
#+END_SRC | ||
* Variables Globales | ||
#+BEGIN_SRC elisp | ||
;; para los org-capture-templates utilice éste como workspace | ||
;; "~/org-files" | ||
(setq org-directory "~/org-files" | ||
org-agenda-files '("doc/pages/tasks.org")) | ||
|
||
;; agregamos el atajo para acceder a la agenda más fácil | ||
(global-set-key (kbd "C-c a") 'org-agenda) | ||
#+END_SRC | ||
* Org Tareas | ||
#+BEGIN_SRC elisp | ||
(setq org-priority-faces '((?A :foreground "#e45649") | ||
(?B :foreground "#da8548") | ||
(?C :foreground "#0098dd")) | ||
org-todo-keywords '((sequence "TODO(t)" "IN PROGRESS(i)" "WAITING(w)" "SOMEDAY(s)" "READ(r)" "DONE(d)")) | ||
org-todo-keyword-faces | ||
'(("TODO" :foreground "#7c7c75" :weight normal :underline t) | ||
("IN PROGRESS" :foregroundeground "#0098dd" :weight normal :underline t) | ||
("SOMEDAY" :foreground "#50a14f" :weight normal :underline t) | ||
("READ" :foreground "#50a14f" :weight normal :underline t) | ||
("DONE" :foreground "#50a14f" :weight normal :underline t) | ||
("WAITING" :foreground "#9f7efe" :weight normal :underline t))) | ||
#+END_SRC | ||
* Org Capture Templates | ||
#+BEGIN_SRC elisp | ||
;; Nota: otra alternativa a la función (projectile-project-root) que devuelve la ruta absoluta, | ||
;; sería la variable local project-root que creamos nosotros en .dir-locals.el | ||
|
||
(defun create-article-file () | ||
"Create an org file in path-my-project/articles/." | ||
(interactive) | ||
(let ((name (read-string "Filename without extension: "))) | ||
(expand-file-name (format "%s.org" name) | ||
(concat (projectile-project-root) "doc/articles/")))) | ||
|
||
(setq org-capture-templates | ||
'(;; Article Templates | ||
("a" "Article") | ||
("an" "New Article" entry | ||
(file (lambda () (call-interactively 'create-article-file))) | ||
(file "templates/article.txt") | ||
) | ||
|
||
;; Video Templates | ||
("v" "Video") | ||
("vt" "Videotutorial" entry | ||
(file+headline | ||
(lambda () ( concat (projectile-project-root) "doc/pages/videos.org")) | ||
"Videotutorials") | ||
(file "templates/video.txt")) | ||
("vo" "Overview" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/videos.org")) | ||
"Overviews") | ||
(file "templates/video.txt")) | ||
("vc" "Conference / Talk" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/videos.org")) | ||
"Conferences / Talks") | ||
(file "templates/video.txt")) | ||
|
||
;; Documentation Templates | ||
("d" "Documentation") | ||
("do" "Official Documentation" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/documentation.org")) | ||
"Official Documentation") | ||
(file "templates/official-documentation.txt")) | ||
("dn" "Non-Official Documentation" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/documentation.org")) | ||
"Non-Official Documentation") | ||
(file "templates/non-official-documentation.txt")) | ||
|
||
;; Issues Templates | ||
("i" "Issue") | ||
("is" "Issues has been Solved" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/issues.org")) | ||
"Issues has been Solved") | ||
(file "templates/issue-solved.txt")) | ||
("in" "Issue needs to be Solved" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/issues.org")) | ||
"Issues need to be Solved") | ||
(file "templates/issue-unsolved.txt")) | ||
|
||
;; Dotfiles Template | ||
("u" "User's Dot File" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/users-dotfiles.org")) | ||
"Users' Dot Files") | ||
(file "templates/user-dotfile.txt")) | ||
|
||
;; Books Template | ||
("b" "Book") | ||
("bn" "New Book" plain | ||
(file+headline | ||
(lambda () ( concat (projectile-project-root) "doc/pages/books.org")) | ||
"Books") | ||
(file "templates/book.txt")) | ||
|
||
;; Nota: | ||
;; 1. usamos "plain" en vez de "entry", éste segundo anidaba otro elemento en el árbol de tareas | ||
;; 2. suponemos que el template ya agregamos los 3 niveles de profundidad | ||
;; 3. en vez de (projectile-project-root) podríamos usar.. (file-name-directory buffer-file-name) | ||
;; pero sólo se podría ejecutar la plantilla dentro del buffer de algún archivo del directorio doc/pages/ | ||
("bc" "New Book Chapter" plain | ||
(file+function (lambda () (concat (projectile-project-root) "doc/pages/books.org")) | ||
(lambda () (call-interactively 'find-title-org-mode))) | ||
(file "templates/book-chapter.txt") | ||
) | ||
|
||
;; Courses Template | ||
("c" "Course") | ||
("cn" "New Course" entry | ||
(file+headline | ||
(lambda () (concat (projectile-project-root) "doc/pages/courses.org")) | ||
"Courses") | ||
(file "templates/course.txt")) | ||
|
||
;; idem que Book Chapter | ||
("cl" "New Course Lesson" plain | ||
(file+function (lambda () (concat (projectile-project-root) "doc/pages/courses.org")) | ||
(lambda () (call-interactively 'find-title-org-mode))) | ||
(file "templates/course-lesson.txt") | ||
))) | ||
|
||
#+END_SRC | ||
* Buscador | ||
#+BEGIN_SRC elisp | ||
(defun find-title-org-mode (&optional title) | ||
;; permite la interacción con el usuario, le solicita ingresar el título a buscar | ||
(interactive "singrese parte del tìtulo a buscar: ") | ||
|
||
;; mueve el cursor al principio del buffer, para que re-search-forward busque desde esa posición | ||
(goto-char 0) | ||
|
||
;; verificamos si encontró la palabra | ||
(if (re-search-forward title nil t) | ||
|
||
;; si lo encontró mueve el cursor a la siguiente título | ||
(outline-next-heading)) | ||
) | ||
#+END_SRC | ||
* Generador de artículos | ||
#+BEGIN_SRC elisp | ||
(defun create-article-file () | ||
"Create an org file in path-my-project/doc/articles/." | ||
(interactive) | ||
(let ((name (read-string "Filename without extension: "))) | ||
(expand-file-name (format "%s.org" name) | ||
(concat (projectile-project-root) "doc/articles/")))) | ||
#+END_SRC |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#+TITLE: Articles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#+TITLE: Books | ||
* Books | ||
** The Mastering Emacs :emacs: | ||
:PROPERTIES: | ||
:STATUS: reading | ||
:LEVEL: normal | ||
:LANGUAGE: english | ||
:RATING: 10/10 | ||
:URL: https://www.learn-clojurescript.com/ | ||
:AUTHOR: Mickey Petersen | ||
:YEAR-PUBLICATION: 2015 | ||
:PAGES: 314 | ||
:ISBN-13: nil | ||
:END: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#+TITLE: Courses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#+TITLE: Documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#+TITLE: Issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#+TITLE: Tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#+TITLE: User's Dot Files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#+TITLE: Videos | ||
#+STARTUP: showall | ||
* Videotutorials |
Oops, something went wrong.