Org-journal won't recognize org-journal-dir? - emacs

Using the following use-package syntax, Org-journal doesn't recognize the org-journal-dir setting--instead, attempts to create a different directory with query Journal directory ~/Documents/journal not found. Create one?:
(use-package org-journal
:ensure t
:custom
(setq org-journal-dir "~/Dropbox/logs/journal/")
(setq org-journal-file-format "%m.%d.%Y.org"))
I see no error messages--it just seems to ignore the directory setting. Is this a simple syntax error? I'm new to the package and to Org mode.
[Update]: Sometimes, I get the following error message on Emacs start:
Error (use-package): org-journal/:catch: Symbol’s value as variable is void: org-journal-dir

The syntax for :custom is wrong. See https://github.com/jwiegley/use-package#customizing-variables. It should be something like:
:custom
(org-journal-dir "~/Dropbox/logs/journal/")
(org-journal-file-format "%m.%d.%Y.org")
Either that, or use :config (or maybe :init, but probably not) with setq:
:config
(setq org-journal-dir "~/Dropbox/logs/journal/")
(setq org-journal-file-format "%m.%d.%Y.org")

Related

How to issue a warning when package is required at runtime

How can I have emacs issue a warning when a package is required at runtime? I want to do something like cl does with its warning,
Warning: cl package required at runtime
I don't see the responsible piece of code in the cl library.
Looks like it comes from byte-compile-file-form-require in bytecomp.el. There's a line (put 'require 'byte-hunk-handler 'byte-compile-file-form-require) which seems to make it hook into require. You can redefine byte-compile-file-form-require to make it warn on other libraries.
You could try something like the following:
(when (assoc '(t byte-compile-file-form-require ((require '<mypkg>)) nil)
(backtrace-frames))
(message "Warning: package <mypkg> required at runtime"))
Note that backtrace-frames is new in Emacs-26, so for earlier Emacsen, you'll need to reproduce it from backtrace-frame or some such. E.g. for earlier Emacsen, you could use macroexp--backtrace:
(when (assoc '(t byte-compile-file-form-require (require '<mypkg>))
(macroexp--backtrace))
(message "Warning: package <mypkg> required at runtime"))

Flycheck-Google-Cpplint is not Configured Correctly

I am trying to install flycheck-google-cpplint in my emacs. But I get this error:
(flycheck-mode 1)
(eval-after-load 'flycheck
'(progn
(require 'flycheck-google-cpplint)
(flycheck-add-next-checker 'c/c++-cppcheck
'c/c++-googlelint 'append)))
(custom-set-variables
'(flycheck-googlelint-verbose "3")
'(flycheck-googlelint-filter "-whitespace,+whitespace/braces"))
But this does not work. I get the following error:
Error: (user-error "Configured syntax checker c/c++-googlelint cannot be used")
I don't know why. I installed cpplint and it works fine if I used it from the command line. Any suggestion?
flycheck-google-lint uses cpplint. You have to tell emacs where to find the cpplint.py executable in order to run the syntax check.
You can find the cpplint file here.
Then, you need to add this to your init emacs file:
(custom-set-variables
'(flycheck-c/c++-googlelint-executable "/path/to/cpplint.py"))

How to make swank working with stumpw?

I've added this code snippet to my stumpwmrc file:
(defun load-swank ()
"Load a swank server"
(ql:quickload 'swank)
(require 'swank)
(setq swank:*use-dedicated-output-stream* nil)
(setq slime-net-coding-system 'utf-8-unix)
(swank:create-server :port 4006))
(load-swank)
I am expecting to open a socket server, accepting the "swank" protocol. Thus I could connect to it with emacs (thanks to Slime).
But when I login and and stumpwm is reading its configuration file, here is the error message I get:
15:00:34 Outputting a message:
^B^1*Error loading ^b/home/ybaumes/.stumpwmrc^B: ^nThe name "SWANK" does not designate any package.
How can I fix that? I invoke 'require, or even 'quickload functions. What's the issue here?
A typical error is this:
You load the file and the reader sees the code:
SWANK is not loaded
(defun load-swank ()
"Load a swank server"
SWANK is not loaded
(ql:quickload 'swank)
SWANK is not loaded - remember, we are still reading the form.
(require 'swank)
SWANK is not loaded - remember, we are still reading the form.
Now use us a symbol in package which is not existing... the reader complains:
(setq swank:*use-dedicated-output-stream* nil) ; the package SWANK does not exist yet.
(setq slime-net-coding-system 'utf-8-unix)
(swank:create-server :port 4006))
Now you want to load SWANK:
(load-swank)
You can't use a symbol from a package which does not exist.
For example what works is this inside the function:
(setf (symbol-value (read-from-string "swank:*use-dedicated-output-stream*")) nil)
and so on.
You need to find the symbol at runtime of that function. Use (find-symbol "FOO" "SWANK") (remember Common Lisp is upcase internally) or (read-from-string "SWANK::FOO").

How do I choose/switch Leiningen profiles with Emacs nREPL?

I have a :dev profile set up in my leiningen project file. This defines an :init and :init-ns setting for my repl session. If I launch nrepl in emacs (M-x nrepl-jack-in) with the cursor over the :dev keyword in my project.clj, the repl launches and the :init and :init-ns settings are used. If I have my cursor elsewhere, the initial namespace is different (a test ns, not user), and :init hasn't been evaluated.
I'm guessing it's a feature of some sort, (I'm more inclined to think it's random buggy behaviour now) but can anyone explain it or point me at the docs that do so? Also, is there any way to change the profile once the repl's been launched?
Thanks
Contrary to what commenter #user7610 said, there is no cider-jack-in-with-profile function in cider. Cider pull-request #544 was a bit misleading in that regard.
If you want cider to load your own special-snowflake profile do this in emacs:
M-x set-variable cider-lein-parameters to e.g. with-profile +my-special-snowflake repl :headless
or to set the variable interactively (so you can see it's current value before changing it):
C-h, v cider-lein-parameters and then click or hit enter on "customize" and set it there to e.g. with-profile +my-special-snowflake repl :headless and apply it
That'll cause your next cider-jack-in to load the my-special-snowflake profile in addition to the base profile (which is needed in order to run the nrepl and hence cider).
Try this:
(defun start-cider-repl-with-profile ()
(interactive)
(letrec ((profile (read-string "Enter profile name: "))
(lein-params (concat "with-profile +" profile " repl :headless")))
(message "lein-params set to: %s" lein-params)
(set-variable 'cider-lein-parameters lein-params)
(cider-jack-in)))
Test on CIDER 0.16.0 (Riga)
I'm just searching the same feature and found this open issue in clojure-emacs/nrepl.el "Add argument to nrepl-jack-in to allow specification of profiles" https://github.com/clojure-emacs/nrepl.el/issues/327
it is still open
I try the function author by Jiacai Liu in my computer(GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109)) of 2019-04-13) . I get a error is:
eval-region: Wrong number of arguments: (1 . 1), 0
And then, I try to elisp function as:
(defun start-cider-repl-with-profile ()
(interactive)
(letrec ((profile (read-string "Enter profile name: "))
(lein-params (concat "with-profile +" profile " repl :headless")))
(message "lein-params set to: %s" lein-params)
(set-variable 'cider-lein-parameters lein-params)
(cider-jack-in '())))
Now it work. Thanks for Jiacai Liu!

Emacs preview-latex minted package and -shell-escape

I'm trying to use emacs with preview-latex (C-c C-p C-b) to view my document. First a minimal example of my document:
\documentclass {article}
\usepackage{minted}
\begin{document}
\begin{listing}[H]
\begin{minted}{sql}
Select * from FOOBAR;
\end{minted}
\caption{Test Query}
\label{code:query}
\end{listing}
\end{document}
I already tried using Using minted (source code LaTeX package) with emacs/auctex the following answer but it does not seem to work with preview-latex.
I get the following error message:
! Package minted Error: You must invoke LaTeX with the -shell-escape flag.
So I changed my latex-mode-hook to the following:
(defun kungi/latex-mode-hook ()
(turn-on-flyspell)
(auto-complete-mode 1)
(turn-on-reftex)
(turn-on-auto-fill-mode)
(push
'("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run Latexmk on file")
TeX-command-list)
(eval-after-load "tex"
'(setcdr (assoc "LaTeX" TeX-command-list)
'("xelatex -shell-escape %t"
TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")))
(add-hook 'LaTeX-mode-hook
'kungi/latex-mode-hook)
Can you please tell me what I am doing wrong? Is it possible to use minted with preview latex?
I am using VIM with the LaTeX_Box plugin and I ran into a similar issue getting the very same error message. I could solve it by simply putting a file with the following contents to ~/.latexmkrc
$latex = 'latex --shell-escape';
$pdflatex = 'pdflatex --shell-escape';