abo-abo/ace-link

Allow to specify a fallback function for ace-link when current mode is not supported

Closed this issue · 1 comments

When current major mode is not supported, it would be nice to optionally specify a function, such as ace-link-org to be used as fallback instead of erroring.

I imagine it could be implemented like this:

(defun ace-link ()
  "Call the ace link function for the current `major-mode'"
  (interactive)
  (cond ((eq major-mode 'Info-mode)
         (ace-link-info))
        ((member major-mode '(help-mode package-menu-mode geiser-doc-mode))
         (ace-link-help))
        ((eq major-mode 'woman-mode)
         (ace-link-woman))
        ((eq major-mode 'eww-mode)
         (ace-link-eww))
        ((or (member major-mode '(compilation-mode grep-mode))
             (bound-and-true-p compilation-shell-minor-mode))
         (ace-link-compilation))
        ((eq major-mode 'gnus-article-mode)
         (ace-link-gnus))
        ((eq major-mode 'org-mode)
         (ace-link-org))
        ((eq major-mode 'Custom-mode)
         (ace-link-org))
        (ace-link-fallback-fnc
         (funcall ace-link-fallback-fnc))
        (t
         (error
          "%S isn't supported"
          major-mode))))

Thanks.