Continued from the previous entry.
If the selected document is html (".html" or ".htm" case insensitive) it opens the document with w3m in a new frame, otherwise it just opens it normally as a text file in the current frame.
hohe2-anything-find.el
(require 'w3m) (require 'anything-config) ;;;; Find (defun hohe2-register-c-source-find (config-symbol title-name find-dir min-required-chars) "Register a new find configuration" (set config-symbol (list `(name . ,title-name) `(candidates . (lambda () (apply 'start-process "find-process" nil (list "find" ,find-dir "-iname" (concat "*" anything-pattern "*")) ))) '(type . findfile) `(requires-pattern . ,min-required-chars) '(delayed)) ) ) (defun hohe2-anything-html-open-method (c) (select-window (frame-selected-window (make-frame))) (w3m-browse-url (concat "file://" c))) (defun hohe2-anything-default-open-method (c) (let ((ext (file-name-extension c))) (if ext (if (member (downcase ext) '("html" "htm")) (hohe2-anything-html-open-method c) (find-file c))))) (add-to-list 'anything-type-attributes '(findfile (action ("Default" . hohe2-anything-default-open-method) ("Browse other window" . (lambda (c) (hohe2-anything-html-open-method c))) ("Browse" . (lambda (c) (w3m-browse-url (concat "file://" c)))) ("Browse with Firefox" . (lambda (c) (shell-command (concat "firefox file://" c)))) ("Open as text" . find-file) ))) (provide 'hohe2-anything-find)
No comments:
Post a Comment