[Refactor] Use expand-file-name instead of concat where possible

This commit is contained in:
Gergely Polonkai 2019-02-19 11:03:18 +01:00
parent f05711f5bf
commit 180ae79080
1 changed files with 14 additions and 25 deletions

View File

@ -568,8 +568,7 @@ name."
(defun gpolonkai/visit-org-index ()
"Visit the root of Org-mode notes."
(interactive)
(find-file-other-window (concat (file-name-as-directory org-directory)
"index.org")))
(find-file-other-window (expand-file-name "index.org" org-directory)))
#+END_SRC
** Frame manipulation
@ -1177,7 +1176,7 @@ Because Im a sysadmin, too.
:ensure nil
:config
(run-at-time nil (* 5 60) 'recentf-save-list)
(add-to-list 'recentf-exclude (concat user-emacs-directory "elpa")))
(add-to-list 'recentf-exclude (expand-file-name "elpa" user-emacs-directory)))
#+END_SRC
** ~files~
@ -1355,7 +1354,7 @@ The cookies are from the Hungarian version an ancient MS-DOS based program calle
(use-package cookie1
:demand t
:config
(setq cookie-file (concat user-emacs-directory "fortune-cookies.txt"))
(setq cookie-file (expand-file-name "fortune-cookies.txt" user-emacs-directory))
:bind
(:map gpolonkai/pers-map
("k" . cookie)))
@ -2665,11 +2664,11 @@ This is a big one; I use a lot of customisation here.
;; Set up capture templates for blog posts and GT2 related notes
(add-to-list 'org-capture-templates
'("p" "Blog post" entry
(file+olp+datetree (lambda () (concat org-directory "blog.org")))
(file+olp+datetree (lambda () (expand-file-name "blog.org" org-directory)))
"* %^{Title} :blog:\n:PROPERTIES:\n:CREATED: %T\n:END:\n\n%i%?"))
(add-to-list 'org-capture-templates
'("g" "GT2 note" entry
(file+headline (lambda () (concat org-directory "gt2-notes.org")) "Captures")
(file+headline (lambda () (expand-file-name "gt2-notes.org" org-directory)) "Captures")
"** %^{Title}\n:PROPERTIES:\n:CREATED: %T\n:END:\n\n%a\n\n%i%?"))
(add-to-list 'org-capture-templates
'("c" "Item to current Clocked Task" item
@ -2725,15 +2724,9 @@ This is a big one; I use a lot of customisation here.
:after
org
:config
(setq org-ref-bibliography-notes (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibliography-notes"))
org-ref-default-bibliography '((concat user-documents-directory
(convert-standard-filename
"/orgmode/references.bib")))
org-ref-pdf-directory (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibtex-pdfs"))))
(setq org-ref-bibliography-notes (expand-file-name "bibliography-notes" org-directory)
org-ref-default-bibliography '((expadn-file-name "references.bib" org-directory))
org-ref-pdf-directory (expand-file-name "bibtex-pdfs" org-directory)))
#+END_SRC
And set up a function to open PDF files with the system pdf viewer, using ~xdg-open~.
@ -3073,15 +3066,11 @@ See previous versions of the current file.
:after
org
:config
(setq bibtex-completion-bibliography (concat user-documents-directory
(convert-standard-filename
"/orgmode/references.bib"))
bibtex-completion-library-path (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibtex-pdfs"))
bibtex-completion-notes-path (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibliography/helm-bibtex-notes"))
(setq bibtex-completion-bibliography (expand-file-name "references.bib" org-directory)
bibtex-completion-library-path (expand-file-name "bibtex-pdfs" org-directory)
bibtex-completion-notes-path (expand-file-name
(convert-standard-filename "bibliography/helm-bibtex-notes")
org-directory)
bibtex-completion-pdf-open-function 'org-open-file))
#+END_SRC
@ -3208,7 +3197,7 @@ directory. It is available from [[http://plantuml.com/download][here]].
;; Make sure we have a download location even if XDG is not working
(cond
((xdg-user-dir "DOWNLOAD")
(concat (xdg-user-dir "DOWNLOAD") "/plantuml.jar"))
(expand-file-name "plantuml.jar" (xdg-user-dir "DOWNLOAD")))
(t
"~/Downloads/plantuml.jar"))))
(defvaralias 'org-plantuml-jar-path 'plantuml-jar-path)