-1
(defun buffer-to-shell()
  (let (buffer mark-whole-buffer)))
  (shell-command-on-region start end "sed s/foo/bar/") ;; start, end not defined
  )

As you might see there are undefined variables start and end in the function call for shell-command-on-region.

I would like the function buffer-to-shell to just mark the whole active buffer and pass it's region fields to the shell command function. I do not know how to get those to fields out of the result of mark-whole-buffer which I am assigning to the local variable buffer (which also may be redundant.

Solution

(defun buffer-to-shell()
  "push the whole buffer to shell command sed"
  (interactive)
  (shell-command-on-region (point-min) (point-max) "sed s/foo/bar/")
  )

yields Wrong type argument: commandp, buffer-to-shell

1

You don't need a region when you're calling this function from code. You only need positions in buffer, and you can get these with (point-min) and (point-max).

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.