this post was submitted on 24 Oct 2023
2 points (100.0% liked)

Emacs

314 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

Hi everyone,

u/daviwil had released an excellent video in his System Crafters channel, where he showed how to hack org-roam:

https://systemcrafters.net/build-a-second-brain-in-emacs/5-org-roam-hacks/

I have copied his code into my config (the function that allows to create a TODO in a project file that we select (or create if not existing) is very useful.

I want to create a similar one: I want to create an event in a select customer file and to create this customer file if it does not exist.

The filter of the nodes with the tags "customer" works, but I am stuck with the definition of the content to insert as the event:

- I want the events to be inserted as subheadings of the heading "History" of the customer file (easy)

- I want the events to be saved as a tree structure:

** Year
*** Month
**** day
***** Event 1
***** Event 2....

I am trying to modify his code, but I always have errors

- I have replaced plain with entry in order to get the content as a heading

- I have replaced file+head+olp in the template definition by file+olp+datetree

 (org-roam-capture- :node (org-roam-node-read
                            nil
                            (my/org-roam-filter-by-tag "customer"))
  :templates '(("p" "project" entry "* %<%u>%?/n%i\n%a"
                                   :if-new (file+olp+datetree "%<%Y%m%d%H%M%S>-${slug}.org"
                                                          "#+title: ${title}\n#+category: ${title}\n#+filetags: project"
                                                          ("History"))))))

But still I get the error save-excursion: Wrong type argument: integer-or-marker-p, nil"

What do I get wrong??

top 6 comments
sorted by: hot top controversial new old
[–] 7890yuiop@alien.top 1 points 1 year ago (1 children)

M-x toggle-debug-on-error should get you a stack trace which will explain what's going on.

[–] fmou67@alien.top 1 points 1 year ago (1 children)

Sorry, I forgot to attach it. I am afraid, I do not understand what is wrong.

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) 
  goto-char(nil) 
  (save-excursion (goto-char p) (let* ((id (and t (org-entry-get p "ID")))) (if id (progn (or (progn (and (memq ... cl-struct-org-roam-node-tags) t)) (signal 'wrong-type-argument (list 'org-roam-node org-roam-capture--node))) (let* ((v org-roam-capture--node)) (aset v 6 id))) (org-entry-put p "ID" (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... org-roam-capture--node))) (aref org-roam-capture--node 6))))) (prog1 (org-id-get) (run-hooks 'org-roam-capture-new-node-hook))) 
  (let (p new-file-p) (let* ((val (org-roam-capture--get-target))) (if (consp val) (let* ((x356 (car-safe val))) (cond ((eq x356 'file) (let* (...) (if ... ...))) ((eq x356 'file+olp) (let* (...) (if ... ...))) ((eq x356 'file+head) (let* (...) (if ... ...))) ((eq x356 'file+head+olp) (let* (...) (if ... ...))) ((eq x356 'file+datetree) (let* (...) (if ... ...))) ((eq x356 'node) (let* (...) (if ... ...))))))) (save-excursion (goto-char p) (let* ((id (and t (org-entry-get p "ID")))) (if id (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... org-roam-capture--node))) (let* ((v org-roam-capture--node)) (aset v 6 id))) (org-entry-put p "ID" (progn (or (progn ...) (signal ... ...)) (aref org-roam-capture--node 6))))) (prog1 (org-id-get) (run-hooks 'org-roam-capture-new-node-hook)))) 
  org-roam-capture--setup-target-location() 
  (cond ((run-hook-with-args-until-success 'org-roam-capture-preface-hook)) (t (org-roam-capture--setup-target-location))) 
  (let ((id (cond ((run-hook-with-args-until-success 'org-roam-capture-preface-hook)) (t (org-roam-capture--setup-target-location))))) (org-roam-capture--adjust-point-for-capture-type) (let ((template (org-capture-get :template))) (if (stringp template) (progn (org-capture-put :template (org-roam-capture--fill-template template))))) (org-roam-capture--put :id id) (org-roam-capture--put :finalize (or (org-capture-get :finalize) (org-roam-capture--get :finalize)))) 
  org-roam-capture--prepare-buffer() 
  funcall(org-roam-capture--prepare-buffer) 
  (let ((fun x253)) (funcall fun) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) 
  (if (null x254) (let ((fun x253)) (funcall fun) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) (let ((target val)) (error "Invalid capture target specification: %S" target))) 
  (let* ((x253 (car-safe x252)) (x254 (cdr-safe x252))) (if (null x254) (let ((fun x253)) (funcall fun) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) (let ((target val)) (error "Invalid capture target specification: %S" target)))) 
  (if (consp x252) (let* ((x253 (car-safe x252)) (x254 (cdr-safe x252))) (if (null x254) (let ((fun x253)) (funcall fun) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p)))) (let ((target val)) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))) 
  (let* ((x252 (cdr-safe val))) (if (consp x252) (let* ((x253 (car-safe x252)) (x254 (cdr-safe x252))) (if (null x254) (let ((fun x253)) (funcall fun) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p ...) (org-at-heading-p)))) (let ((target val)) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target)))) 
  (cond ((eq x223 'here) (let* ((x224 (cdr-safe val))) (if (null x224) (funcall pcase-0) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file) (let* ((x225 (cdr-safe val))) (if (consp x225) (let* ((x226 (car-safe x225)) (x227 (cdr-safe x225))) (if (null x227) (let (...) (set-buffer ...) (org-capture-put-target-region-and-position) (widen) (setq target-entry-p nil)) (let (...) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'id) (let* ((x228 (cdr-safe val))) (if (consp x228) (let* ((x229 (car-safe x228)) (x230 (cdr-safe x228))) (if (null x230) (let (...) (let* ... ...)) (let (...) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+headline) (let* ((x231 (cdr-safe val))) (if (consp x231) (let* ((x232 (car-safe x231)) (x233 (cdr-safe x231))) (if (consp x233) (let* (... ...) (if ... ... ...)) (let (...) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+olp) (let* ((x236 (cdr-safe val))) (if (consp x236) (let* ((x237 (car-safe x236)) (x238 (cdr-safe x236))) (let ((path x237) (outline-path x238)) (let (...) (set-buffer ...) (org-capture-put-target-region-and-position) (widen) (goto-char m) (set-marker m nil)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+regexp) (let* ((x239 (cdr-safe val))) (if (consp x239) (let* ((x240 (car-safe x239)) (x241 (cdr-safe x239))) (if (consp x241) (let* (... ...) (if ... ... ...)) (let (...) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+olp+datetree) (let* ((x244 (cdr-safe val))) (if (consp x244) (let* ((x245 (car-safe x244)) (x246 (cdr-safe x244))) (let ((path x245) (outline-path x246)) (let (...) (set-buffer ...) (org-capture-put-target-region-and-position) (widen) (goto-char m) (set-marker m nil) (require ...) (org-capture-put-target-region-and-position) (widen) (funcall ... ... ...)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+function) (let* ((x247 (cdr-safe val))) (if (consp x247) (let* ((x248 (car-safe x247)) (x249 (cdr-safe x247))) (if (consp x249) (let* (... ...) (if ... ... ...)) (let (...) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'function) (let* ((x252 (cdr-safe val))) (if (consp x252) (let* ((x253 (car-safe x252)) (x254 (cdr-safe x252))) (if (null x254) (let (...) (funcall fun) (org-capture-put :exact-position ...) (setq target-entry-p ...)) (let (...) (error "Invalid capture target specification: %S" target)))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'clock) (let* ((x255 (cdr-safe val))) (if (null x255) (let nil (if (and (markerp org-clock-hd-marker) (marker-buffer org-clock-hd-marker)) (progn (set-buffer ...) (org-capture-put-target-region-and-position) (widen) (goto-char org-clock-hd-marker)) (user-error "No running clock that could be used as capture tar..."))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) (t (let ((target val)) (error "Invalid capture target specification: %S" target)))) 
  (let* ((x223 (car-safe val))) (cond ((eq x223 'here) (let* ((x224 (cdr-safe val))) (if (null x224) (funcall pcase-0) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file) (let* ((x225 (cdr-safe val))) (if (consp x225) (let* ((x226 ...) (x227 ...)) (if (null x227) (let ... ... ... ... ...) (let ... ...))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'id) (let* ((x228 (cdr-safe val))) (if (consp x228) (let* ((x229 ...) (x230 ...)) (if (null x230) (let ... ...) (let ... ...))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+headline) (let* ((x231 (cdr-safe val))) (if (consp x231) (let* ((x232 ...) (x233 ...)) (if (consp x233) (let* ... ...) (let ... ...))) (let ((target val)) (error "Invalid capture target specification: %S" target))))) ((eq x223 'file+olp) (let* ((x236 (cdr-safe val))) (if (consp x236) (let* ((x237 ...) (x238 ...)) (let (... ...) (let ... ... ... ... ... ...))) (let ((target val)) (error "Invalid capture  

[–] 7890yuiop@alien.top 1 points 1 year ago (2 children)

Could you fix the formatting?

The only code block formatting method which works for all users of reddit is to switch the reddit editor to markdown mode* and indent the code by 4 spaces (you can use M-4 C-x C-i on a region followed by M-x untabify to achieve this in Emacs); and you need to use empty lines to separate the indented lines from the other text. Otherwise for lots of readers your message looks like this: https://old.reddit.com/r/emacs/comments/17etbx8/saveexcursion_wrong_type_argument/k685ohy/

Be sure to remove any different syntax intended for formatting (such as triple backticks) at the same time.

(*) Switching to the markdown editor may or may not still be necessary. At one time it prevented problems.

[–] fmou67@alien.top 1 points 1 year ago

I will, thx

[–] fmou67@alien.top 1 points 1 year ago (1 children)

I have difficulties with the formatting, are you still able to read and write in Reddit via Emacs?
What package do you use? md4rd?

[–] 7890yuiop@alien.top 1 points 1 year ago

I read reddit in Firefox and I make use of https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/ , but you can also just copy/paste between the markdown editor and emacs.