Skip to main content
added 18 characters in body
Source Link
;; comment
(eval-after-load 'elfeed-search
  '(define-key elfeed-search-mode-map "d" #'my/baa))

;; comment
(defun my/baa ()
  (interactive)
  (let ((var "value-of-variable"))

  (async-start
   ;; What to do in the child process
   `(lambda ()
     (sleep-for 3) ;; future curl call
     ,(format "This is a %s" var))

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be something: %s"
              result))))

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

;; comment
(defun my/baa ()
  (interactive)
  (let ((var "value-of-variable"))

  (async-start
   ;; What to do in the child process
   `(lambda ()
     (sleep-for 3)
     ,(format "This is a %s" var))

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be something: %s"
              result))))

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

;; comment
(defun my/baa ()
  (interactive)
  (let ((var "value-of-variable"))

  (async-start
   ;; What to do in the child process
   `(lambda ()
     (sleep-for 3) ;; future curl call
     ,(format "This is a %s" var))

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be something: %s"
              result))))

  (next-line))
added 702 characters in body
Source Link

Here's some background on what I'm trying to achieve. I have a RSS feed that has a steady steam of new articles. The feed lacks some key information. Let's say the feed is about companies listed in NYSE, and I would like to see the current stock price of the feed item. Since this info is available via the web via a seperate curl call, my solution is to bind letter "d" to an elisp function "my/baa". This function is non blocking. It is passed a reference to the currently selected elfeed item. When the (async) function returns, it prepends the stock price value to the line in the elfeed-search mode buffer. This is done through the "meta attribute" mechanism provided by elfeed. basically, any feed item can have a meta information. so the async function adds a meta inf to the elfeed item, and then triggers a ui update/refresh. I can hold down the d key press, and this will trigger a bunch of async's to fetch multiple http requests to get multiple stock quotes. this is non blocking. when the function returns, the display will get updated. each finish of an async function will trigger a redraw of the elfeed-search buffer.

Update 2: Tyler said the comma and backtick is crucial, so I added them, but still get the same error. Here's my edited code:

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

;; comment
(defun my/baa ()
  (interactive)
  (let ((var "value-of-variable"))

  (async-start
   ;; What to do in the child process
   `(lambda ()
     (sleep-for 3)
     ,(format "This is a %s" var))

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be something: %s"
              result))))

  (next-line))

Here's some background on what I'm trying to achieve. I have a RSS feed that has a steady steam of new articles. The feed lacks some key information. Let's say the feed is about companies listed in NYSE, and I would like to see the current stock price of the feed item. Since this info is available via the web via a seperate curl call, my solution is to bind letter "d" to an elisp function "my/baa". This function is non blocking. It is passed a reference to the currently selected elfeed item. When the (async) function returns, it prepends the stock price value to the line in the elfeed-search mode buffer. I can hold down the d key press, and this will trigger a bunch of async's to fetch multiple http requests to get multiple stock quotes. this is non blocking. when the function returns, the display will get updated. each finish of an async function will trigger a redraw of the elfeed-search buffer.

Here's some background on what I'm trying to achieve. I have a RSS feed that has a steady steam of new articles. The feed lacks some key information. Let's say the feed is about companies listed in NYSE, and I would like to see the current stock price of the feed item. Since this info is available via the web via a seperate curl call, my solution is to bind letter "d" to an elisp function "my/baa". This function is non blocking. It is passed a reference to the currently selected elfeed item. When the (async) function returns, it prepends the stock price value to the line in the elfeed-search mode buffer. This is done through the "meta attribute" mechanism provided by elfeed. basically, any feed item can have a meta information. so the async function adds a meta inf to the elfeed item, and then triggers a ui update/refresh. I can hold down the d key press, and this will trigger a bunch of async's to fetch multiple http requests to get multiple stock quotes. this is non blocking. when the function returns, the display will get updated. each finish of an async function will trigger a redraw of the elfeed-search buffer.

Update 2: Tyler said the comma and backtick is crucial, so I added them, but still get the same error. Here's my edited code:

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

;; comment
(defun my/baa ()
  (interactive)
  (let ((var "value-of-variable"))

  (async-start
   ;; What to do in the child process
   `(lambda ()
     (sleep-for 3)
     ,(format "This is a %s" var))

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be something: %s"
              result))))

  (next-line))
added 1004 characters in body; edited tags
Source Link

How can I pass a stringvariable in to this function, so that instead of printing "This is a test", it prints "This is a value-of-variable"

(async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a test")
     (sleep-for 3)
     222)

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be 222: %s" result)))

Update: I tried the answer suggested by @Tobias. Didn't work. Here's my code

;; ~/prelude/personal.el
(eval-after-load 'elfeed-search
  '(define-key elfeed-search-mode-map "d" #'my/baa))

;; comment
(defun my/baa ()
  (interactive )
  (let ((var "value-of-variable"))
  

  ;;(message "here %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)))
  (async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a %s" var)
     (sleep-for 2)
     var)

   ;; What to do when it finishes
   (lambda (result)
     (message "%s Async process done, result should be 222: %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)) result))))

  (next-line)
  ))

To test it, I would place point/cursor on a elfeed RSS feed item, and press letter d. I see in the minibuffer:

error in process sentinel: Symbol’s value as variable is void: var

By the way, as you can see, I suck at elisp indentation. How can I tell emacs to fix the indentation of the above code block.

Here's some background on what I'm trying to achieve. I have a RSS feed that has a steady steam of new articles. The feed lacks some key information. Let's say the feed is about companies listed in NYSE, and I would like to see the current stock price of the feed item. Since this info is available via the web via a seperate curl call, my solution is to bind letter "d" to an elisp function "my/baa". This function is non blocking. It is passed a reference to the currently selected elfeed item. When the (async) function returns, it prepends the stock price value to the line in the elfeed-search mode buffer. I can hold down the d key press, and this will trigger a bunch of async's to fetch multiple http requests to get multiple stock quotes. this is non blocking. when the function returns, the display will get updated. each finish of an async function will trigger a redraw of the elfeed-search buffer.

How can I pass a stringvariable in to this function, so that instead of printing "This is a test", it prints "This is a value-of-variable"

(async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a test")
     (sleep-for 3)
     222)

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be 222: %s" result)))

Update: I tried the answer suggested by @Tobias. Didn't work. Here's my code

;; ~/prelude/personal.el
(eval-after-load 'elfeed-search
  '(define-key elfeed-search-mode-map "d" #'my/baa))

;; comment
(defun my/baa ()
  (interactive )
  (let ((var "value-of-variable"))
  

  ;;(message "here %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)))
  (async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a %s" var)
     (sleep-for 2)
     var)

   ;; What to do when it finishes
   (lambda (result)
     (message "%s Async process done, result should be 222: %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)) result))))

  (next-line)
  ))

To test it, I would place point/cursor on a elfeed RSS feed item, and press letter d. I see in the minibuffer:

error in process sentinel: Symbol’s value as variable is void: var

By the way, as you can see, I suck at elisp indentation. How can I tell emacs to fix the indentation of the above code block.

How can I pass a stringvariable in to this function, so that instead of printing "This is a test", it prints "This is a value-of-variable"

(async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a test")
     (sleep-for 3)
     222)

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be 222: %s" result)))

Update: I tried the answer suggested by @Tobias. Didn't work. Here's my code

;; ~/prelude/personal.el
(eval-after-load 'elfeed-search
  '(define-key elfeed-search-mode-map "d" #'my/baa))

;; comment
(defun my/baa ()
  (interactive )
  (let ((var "value-of-variable"))
  

  ;;(message "here %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)))
  (async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a %s" var)
     (sleep-for 2)
     var)

   ;; What to do when it finishes
   (lambda (result)
     (message "%s Async process done, result should be 222: %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)) result))))

  (next-line)
  ))

To test it, I would place point/cursor on a elfeed RSS feed item, and press letter d. I see in the minibuffer:

error in process sentinel: Symbol’s value as variable is void: var

By the way, as you can see, I suck at elisp indentation. How can I tell emacs to fix the indentation of the above code block.

Here's some background on what I'm trying to achieve. I have a RSS feed that has a steady steam of new articles. The feed lacks some key information. Let's say the feed is about companies listed in NYSE, and I would like to see the current stock price of the feed item. Since this info is available via the web via a seperate curl call, my solution is to bind letter "d" to an elisp function "my/baa". This function is non blocking. It is passed a reference to the currently selected elfeed item. When the (async) function returns, it prepends the stock price value to the line in the elfeed-search mode buffer. I can hold down the d key press, and this will trigger a bunch of async's to fetch multiple http requests to get multiple stock quotes. this is non blocking. when the function returns, the display will get updated. each finish of an async function will trigger a redraw of the elfeed-search buffer.

added 1004 characters in body; edited tags
Source Link
Loading
edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Loading
Source Link
Loading