2

When I press "d", this loop runs 52 times. How can I adjust this elisp so that, I can specify a number instead of harcoding 52.

I guess I'm trying to do something like " C-u -1 C-x ^" mentioned at https://www.emacswiki.org/emacs/WindowResize

;; comment                                                                                                                     
(eval-after-load 'elfeed-search
  '(define-key elfeed-search-mode-map "d" #'my/elfeed-extra-info))                                                             

;; fetches extra info                                                                                                          
(defun my/elfeed-extra-info ()
  (interactive)
  (dotimes (i 52)
    (elfeed-goto-line i)                                                                       
    (my/detect-country (elfeed-search-selected :ignore-region))
    (my/detect-isfp      (elfeed-search-selected :ignore-region))
    (my/detect-others (elfeed-search-selected :ignore-region))
    (elfeed-search-update :force)                                                                                                                               
    )                                                                                                                          
)
2

Pass the number of times as the numeric prefix arg. See the Elisp manual, node Prefix Command Arguments and node Using `interactive'.

(defun my/elfeed-extra-info (&optional numtimes) ; <=== Add an argument
  (interactive "p") ; <=== Supply numeric prefix arg interactively
  (dotimes (i  numtimes)
    (elfeed-goto-line i)                                                                       
    (my/detect-country (elfeed-search-selected :ignore-region))
    (my/detect-isfp (elfeed-search-selected :ignore-region))
    (my/detect-others (elfeed-search-selected :ignore-region))
    (elfeed-search-update :force)))

UPDATE after your new request (you really should edit your question, or better yet, pose a new question rather than changing the request):

(defun my/elfeed-extra-info (&optional numtimes)
  (interactive (list (if current-prefix-arg ; <=== User provided arg
                         (prefix-numeric-value current-prefix-arg)
                       52))) ; <=== Default
  (dotimes (i  numtimes)
    (elfeed-goto-line i)                                                                       
    (my/detect-country (elfeed-search-selected :ignore-region))
    (my/detect-isfp (elfeed-search-selected :ignore-region))
    (my/detect-others (elfeed-search-selected :ignore-region))
    (elfeed-search-update :force)))
  • can I still press d and emacs uses 52 as a default – american-ninja-warrior Aug 29 '18 at 22:11
  • Updated to answer that. – Drew Aug 29 '18 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.