Hacker News new | past | comments | ask | show | jobs | submit login

Do you still have that script? I would be interested in checking that out.



I replied a couple comments below w a fuller explanation but here's the relevant emacs functions, code only.

(defun opyn (arg) "Open local file in Firefox" (interactive) (let ((filearg (concat "file:///home/julian/Lang/Python/Something/" arg ".html"))) (shell-command (concat "chromium " filearg))) (message "opened file") )

(defun refresh (arg) "Rerun local file creation & open in Firefox" (interactive) (let ((filearg (concat "ruby project_refresh_emacs.rb " arg))) (shell-command filearg)) (message "refreshed file for you") )


I would, as well. Very neat idea and I'm in a Discord server where I'd get some utility from this sort of thing.


Here's the meat of it.

First, you have an API or something which is piping text into your terminal - in this case, into eshell.

Like for example let's say it's churning out lines like this:

"big vote in berlin" https://cnn.com/vote-in-berlin

I move my cursor over the text - remember, this is in emacs in eshell, I can modify the text there - and change the line to read:

"big vote in berlin" (opyn https://cnn.com/vote-in-berlin)

I move my cursor after the parenthesis and type C-x C-e.

In my .emacs file I've defined this function:

(defun opyn (arg) "Open local file in Firefox" (interactive) (let ((filearg (concat "file:///home/julian/Lang/Python/Something/" arg ".html"))) (shell-command (concat "chromium " filearg))) (message "opened file") )

Now it opens that file.

But probably what you want to do is process the data in the text. So here's my emacs function for this (not the code for the data processing itself which was done in Python, separately - but see how you can go combine those together).

(defun refresh (arg) "Rerun local file creation & open in Firefox" (interactive) (let ((filearg (concat "ruby project_refresh_emacs.rb " arg))) (shell-command filearg)) (message "refreshed file for you") )

That's pretty much it. Hope that helps.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: