Function: apropos--documentation-add-from-elc

apropos--documentation-add-from-elc is a byte-compiled function defined in apropos.el.gz.

Signature

(apropos--documentation-add-from-elc FILE DEFS)

Source Code

;; Defined in /usr/src/emacs/lisp/apropos.el.gz
(defun apropos--documentation-add-from-elc (file defs)
  (erase-buffer)
  (insert-file-contents
   (if (file-name-absolute-p file) file
     (expand-file-name file lisp-directory)))
  (pcase-dolist (`(,symbol ,begbyte ,pos) defs)
    ;; We presume the file-bytes are the same as the buffer bytes,
    ;; which should indeed be the case because .elc files use the
    ;; `emacs-internal' encoding.
    (let* ((beg (byte-to-position (+ (point-min) begbyte)))
           (sizeend (1- beg))
           (size (save-excursion
                   (goto-char beg)
                   (skip-chars-backward " 0-9")
                   (cl-assert (looking-back "#@" (- (point) 2)))
                   (string-to-number (buffer-substring (point) sizeend))))
           (end (byte-to-position (+ begbyte size -1))))
      (when (save-restriction
	      ;; match ^ and $ relative to doc string
	      (narrow-to-region beg end)
	      (goto-char (point-min))
	      (re-search-forward apropos-all-words-regexp nil t))
	(let ((doc (buffer-substring beg end)))
	  (when (apropos-true-hit-doc doc)
	    (apropos--documentation-add symbol doc pos)))))))