Function: ruby-find-library-file

ruby-find-library-file is an interactive and byte-compiled function defined in ruby-mode.el.gz.

Signature

(ruby-find-library-file &optional FEATURE-NAME)

Documentation

Visit a library file denoted by FEATURE-NAME.

FEATURE-NAME is a relative file name, file extension is optional. This commands delegates to gem which, which searches both installed gems and the standard library. When called interactively, defaults to the feature name in the require or gem statement around point.

Probably introduced at or before Emacs version 27.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ruby-mode.el.gz
(defun ruby-find-library-file (&optional feature-name)
  "Visit a library file denoted by FEATURE-NAME.
FEATURE-NAME is a relative file name, file extension is optional.
This commands delegates to `gem which', which searches both
installed gems and the standard library.  When called
interactively, defaults to the feature name in the `require'
or `gem' statement around point."
  (interactive)
  (unless feature-name
    (let ((init (save-excursion
                  (forward-line 0)
                  (when (looking-at "\\(?:require\\| *gem\\) [\"']\\(.*?\\)[\"']")
                    (match-string 1)))))
      (setq feature-name (read-string "Feature name: " init))))
  (let ((out
         (substring
          (shell-command-to-string (concat "gem which " (shell-quote-argument feature-name)))
          0 -1)))
    (if (string-match-p "\\`ERROR" out)
        (user-error "%s" out)
      (find-file out))))