Problems arise when you have multiple browsers and they fight to be your preferred one. In a coworker's box, it tries to open konqueror (WTF?!).
One way to fix the issue is changing browse-url-browser-function.
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "chromium-browser")
Not only that, but the nice thing would be that emacs reused a browser if you have one opened (firefox or chrome) and opened a new one (chrome) otherwise.
I've been messing a bit with proced.el to find out how to list external processes programmatically, but had no luck. If I find out how, I 'll modify this post with new info.
If you have related info, please, comment :)
Thanks to Davazp that pointed me to list-system-processes function, I just wrote the code to use an already opened browser to open a given url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun is-proc-opened (procname) | |
(let ((procs (list-system-processes))) | |
(remove-if-not (lambda (proc) | |
(search procname | |
(name-of-proccess proc))) | |
procs))) | |
(defun name-of-process (proc) | |
(cdr (car (process-attributes proc)))) | |
(defun browse-url-open-browser (url &rest new-window) | |
(setq browse-url-generic-program (open-browser)) | |
(apply 'browse-url-generic url new-window)) | |
(defun open-browser () | |
"define the priorities of browsers" | |
(if (is-proc-opened "chromium") | |
"chromium-browser" | |
(if (is-proc-opened "firefox") | |
"firefox" | |
"chromium-browser"))) | |
(setq browse-url-browser-function 'browse-url-open-browser) |
A good quickreference to look for function signature differences between elisp, scheme and cl is here. It helps quite a lot
1 comentario:
I think you are looking for LIST-PROCESSES. It is described in the Elisp manual. Also, you have LIST-SYSTEM-PROCESSES if you want to list all system processes.
I hope this helps!
Publicar un comentario