Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax for setting variables org-download-image-dir wrong-type-argument stringp nil #218

Open
rickalex21 opened this issue Oct 6, 2024 · 0 comments

Comments

@rickalex21
Copy link

Hello, thank you for your contribution to this project.

I am getting this error. It looks like I can not set the variable dynamically. I am
not sure if something has changed in Emacs recently or if I am doing something
wrong? I have seen several users use the concat function like this.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-base(nil)
  (concat "./images/" (file-name-base (buffer-file-name)) "/")

As a work around I put it in a let:

(evil-define-key 'normal org-mode-map (kbd "C-v") (lambda ()(interactive) ; mac requires brew pngpaste - add ctrl use cmd+ctrl+shift+4
                                                      (let* ((name (read-string "Enter file name without extension:"))
                                                              (org-download-image-dir (concat  "./images/" (file-name-base (buffer-file-name)) "/" ))
                                                              (org-download-screenshot-basename (concat name (format-time-string "-%Y-%m-%dT%H%M%S") ".png")))
                                                      (org-download-clipboard (concat name ".png")))))

Here is my full configuration:

(use-package org-download
  :straight t
  :after org
  :hook ((org-mode dired-mode) . org-download-enable)
  :init
  (setq-default org-download-screenshot-method
                (if (featurep :system 'linux) "grim -g \"$(slurp)\" %s"
                     "screencapture -i %s")) ; assume 'macos
  (setq org-download-image-dir (concat  "./images/" (file-name-base (buffer-file-name)) "/" )
        org-download-heading-lvl nil ; Removes the dir it creates based on the heading
        org-download-image-attr-list '("#+caption:" "#+attr_latex: :width 1500pt" "#+attr_org: :width 500") ; was 450px
        org-download-timestamp  "" ; do not add timestamp at the start of the name
        org-download-annotate-function (lambda (_link) "")) ; Remove #+DOWNLOAD
  :config
  (evil-define-key 'normal org-mode-map (kbd "C-v") (lambda ()(interactive) ; mac requires brew pngpaste - add ctrl use cmd+ctrl+shift+4
                                                      (let* ((name (read-string "Enter file name without extension:"))
                                                              (org-download-image-dir (concat  "./images/" (file-name-base (buffer-file-name)) "/" ))
                                                              (org-download-screenshot-basename (concat name (format-time-string "-%Y-%m-%dT%H%M%S") ".png")))
                                                      (org-download-clipboard (concat name ".png"))))))

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant