;; (point-min), which is acceptable in this case.
:type 'regexp
:group 'xref
- :version "25.0")
+ :version "25.1")
(defcustom find-alias-regexp
"(defalias +'%s"
should insert the feature name."
:type 'regexp
:group 'xref
- :version "25.0")
+ :version "25.1")
(defvar find-function-regexp-alist
'((nil . find-function-regexp)
LIBRARY should be a string (the name of the library)."
;; If the library is byte-compiled, try to find a source library by
;; the same name.
- (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
- (setq library (replace-match "" t t library)))
+ (when (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
+ (setq library (replace-match "" t t library)))
(or
(locate-file library
- (or find-function-source-path load-path)
- (find-library-suffixes))
+ (or find-function-source-path load-path)
+ (find-library-suffixes))
(locate-file library
- (or find-function-source-path load-path)
- load-file-rep-suffixes)
+ (or find-function-source-path load-path)
+ load-file-rep-suffixes)
(when (file-name-absolute-p library)
(let ((rel (find-library--load-name library)))
(when rel
(locate-file rel
(or find-function-source-path load-path)
load-file-rep-suffixes)))))
+ (find-library--from-load-path library)
(error "Can't find library %s" library)))
+(defun find-library--from-load-path (library)
+ ;; In `load-history', the file may be ".elc", ".el", ".el.gz", and
+ ;; LIBRARY may be "foo.el" or "foo", so make sure that we get all
+ ;; potential matches, and then see whether any of them lead us to an
+ ;; ".el" or an ".el.gz" file.
+ (let* ((elc-regexp "\\.el\\(c\\(\\..*\\)?\\)\\'")
+ (suffix-regexp
+ (concat "\\("
+ (mapconcat 'regexp-quote (find-library-suffixes) "\\'\\|")
+ "\\|" elc-regexp "\\)\\'"))
+ (potentials
+ (mapcar
+ (lambda (entry)
+ (if (string-match suffix-regexp (car entry))
+ (replace-match "" t t (car entry))
+ (car entry)))
+ (seq-filter
+ (lambda (entry)
+ (string-match
+ (concat "\\`"
+ (regexp-quote
+ (replace-regexp-in-string suffix-regexp "" library))
+ suffix-regexp)
+ (file-name-nondirectory (car entry))))
+ load-history)))
+ result)
+ (dolist (file potentials)
+ (dolist (suffix (find-library-suffixes))
+ (when (not result)
+ (cond ((file-exists-p file)
+ (setq result file))
+ ((file-exists-p (concat file suffix))
+ (setq result (concat file suffix)))))))
+ result))
+
(defvar find-function-C-source-directory
(let ((dir (expand-file-name "src" source-directory)))
(if (file-accessible-directory-p dir) dir))
(cons (current-buffer) (match-beginning 0))))
;;;###autoload
-(defun find-library (library)
+(defun find-library (library &optional other-window)
"Find the Emacs Lisp source of LIBRARY.
-LIBRARY should be a string (the name of the library)."
+LIBRARY should be a string (the name of the library). If the
+optional OTHER-WINDOW argument (i.e., the command argument) is
+specified, pop to a different window before displaying the
+buffer."
(interactive
(let* ((dirs (or find-function-source-path load-path))
(suffixes (find-library-suffixes))
(when (and def (not (test-completion def table)))
(setq def nil))
(list
- (completing-read (if def (format "Library name (default %s): " def)
+ (completing-read (if def
+ (format "Library name (default %s): " def)
"Library name: ")
- table nil nil nil nil def))))
- (let ((buf (find-file-noselect (find-library-name library))))
- (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
+ table nil nil nil nil def)
+ current-prefix-arg)))
+ (prog1
+ (funcall (if other-window
+ 'pop-to-buffer
+ 'pop-to-buffer-same-window)
+ (find-file-noselect (find-library-name library)))
+ (run-hooks 'find-function-after-hook)))
;;;###autoload
(defun find-function-search-for-symbol (symbol type library)
(require 'tabulated-list)
(require 'macroexp)
+(require 'url-handlers)
(defgroup package nil
"Manager for Emacs Lisp packages."
file)
(defvar generated-autoload-file)
+(defvar autoload-timestamps)
(defvar version-control)
(defun package-generate-autoloads (name pkg-dir)
(let* ((auto-name (format "%s-autoloads.el" name))
;;(ignore-name (concat name "-pkg.el"))
(generated-autoload-file (expand-file-name auto-name pkg-dir))
+ ;; We don't need 'em, and this makes the output reproducible.
+ (autoload-timestamps nil)
;; Silence `autoload-generate-file-autoloads'.
(noninteractive inhibit-message)
(backup-inhibited t)
((derived-mode-p 'tar-mode)
(package-tar-file-info))
(t
- (package-buffer-info))))
+ (save-excursion
+ (package-buffer-info)))))
(name (package-desc-name pkg-desc)))
;; Download and install the dependencies.
(let* ((requires (package-desc-reqs pkg-desc))
(insert "\n")
(unless (and pkg-dir (not archive)) ; Installed pkgs don't have archive.
(package--print-help-section "Archive"
- (or archive "n/a") "\n"))
+ (or archive "n/a")))
(and version
(package--print-help-section "Version"
(package-version-join version)))
(when (null (cdr yank-menu))
(setq saved-yank-menu (copy-sequence yank-menu))
(menu-bar-update-yank-menu "(any string)" nil))
- (setq key (read-key-sequence "Describe key (or click or menu item): "))
+ (while
+ (progn
+ (setq key (read-key-sequence "Describe the following key, mouse click, or menu item: "))
+ (and (vectorp key)
+ (consp (aref key 0))
+ (symbolp (car (aref key 0)))
+ (string-match "\\(mouse\\|down\\|click\\|drag\\)"
+ (symbol-name (car (aref key 0))))
+ (not (sit-for (/ double-click-time 1000.0) t)))))
;; Clear the echo area message (Bug#7014).
(message nil)
;; If KEY is a down-event, read and discard the
(when (null (cdr yank-menu))
(setq saved-yank-menu (copy-sequence yank-menu))
(menu-bar-update-yank-menu "(any string)" nil))
- (setq key (read-key-sequence "Describe key (or click or menu item): "))
+ (while
+ (progn
+ (setq key (read-key-sequence "Describe the following key, mouse click, or menu item: "))
+ (and (vectorp key)
+ (consp (aref key 0))
+ (symbolp (car (aref key 0)))
+ (string-match "\\(mouse\\|down\\|click\\|drag\\)"
+ (symbol-name (car (aref key 0))))
+ (not (sit-for (/ double-click-time 1000.0) t)))))
(list
key
(prefix-numeric-value current-prefix-arg)
(let ((mode-function (nth 0 mode))
(pretty-minor-mode (nth 1 mode))
(indicator (nth 2 mode)))
- (add-text-properties 0 (length pretty-minor-mode)
- '(face bold) pretty-minor-mode)
(save-excursion
(goto-char (point-max))
(princ "\n\f\n")
(push (point-marker) help-button-cache)
;; Document the minor modes fully.
- (insert pretty-minor-mode)
+ (insert-text-button
+ pretty-minor-mode 'type 'help-function
+ 'help-args (list mode-function)
+ 'button '(t))
(princ (format " minor mode (%s):\n"
(if (zerop (length indicator))
"no indicator"
(if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "")
"\n\n")
(if (stringp arglist)
- (if (string-match "\\`[^ ]+\\(\\(?:.\\|\n\\)*\\))\\'" arglist)
+ (if (string-match "\\`[^ ]+\\(.*\\))\\'" arglist)
(concat "(fn" (match-string 1 arglist) ")")
(error "Unrecognized usage format"))
(help--make-usage-docstring 'fn arglist)))))
(define-obsolete-function-alias 'help-make-usage 'help--make-usage "25.1")
(defun help--make-usage-docstring (fn arglist)
- (help--docstring-quote (format "%S" (help--make-usage fn arglist))))
+ (let ((print-escape-newlines t))
+ (help--docstring-quote (format "%S" (help--make-usage fn arglist)))))
\f
(provide 'help)
(eval-when-compile (append "=({[,:;" '(nil))))))
(put-text-property (match-beginning 1) (match-end 1)
'syntax-table (string-to-syntax "\"/"))
- (js-syntax-propertize-regexp end))))))
+ (js-syntax-propertize-regexp end)))))
+ ("\\`\\(#\\)!" (1 "< b")))
(point) end))
(defconst js--prettify-symbols-alist
"Regular expression matching variable declaration keywords.")
(defconst js--indent-operator-re
- (concat "[-+*/%<>&^|?:.]\\([^-+*/]\\|$\\)\\|!?=\\|"
+ (concat "[-+*/%<>&^|?:.]\\([^-+*/.]\\|$\\)\\|!?=\\|"
(js--regexp-opt-symbol '("in" "instanceof")))
"Regexp matching operators that affect indentation of continued expressions.")
"Fill the paragraph with `c-fill-paragraph'."
(interactive "*P")
(let ((js--filling-paragraph t)
- (fill-paragraph-function 'c-fill-paragraph))
+ (fill-paragraph-function #'c-fill-paragraph))
(c-fill-paragraph justify)))
;;; Type database and Imenu
(unwind-protect
+ ;; FIXME: Don't impose IDO on the user.
(setq selected-tab-cname
(let ((ido-minibuffer-setup-hook
(cons #'setup-hook ido-minibuffer-setup-hook)))
(define-derived-mode js-mode prog-mode "JavaScript"
"Major mode for editing JavaScript."
:group 'js
- (setq-local indent-line-function 'js-indent-line)
- (setq-local beginning-of-defun-function 'js-beginning-of-defun)
- (setq-local end-of-defun-function 'js-end-of-defun)
+ (setq-local indent-line-function #'js-indent-line)
+ (setq-local beginning-of-defun-function #'js-beginning-of-defun)
+ (setq-local end-of-defun-function #'js-end-of-defun)
(setq-local open-paren-in-column-0-is-defun-start nil)
- (setq-local font-lock-defaults (list js--font-lock-keywords))
+ (setq-local font-lock-defaults '(js--font-lock-keywords))
(setq-local syntax-propertize-function #'js-syntax-propertize)
(setq-local prettify-symbols-alist js--prettify-symbols-alist)
;; Comments
(setq-local comment-start "// ")
(setq-local comment-end "")
- (setq-local fill-paragraph-function 'js-c-fill-paragraph)
+ (setq-local fill-paragraph-function #'js-c-fill-paragraph)
;; Parse cache
(add-hook 'before-change-functions #'js--flush-caches t t)
(ert-deftest ruby-slash-char-literal-is-not-mistaken-for-regexp ()
(ruby-assert-state "?/" 3 nil))
+ (ert-deftest ruby-regexp-is-not-mistaken-for-slash-symbol ()
+ (ruby-assert-state "x = /foo:/" 3 nil))
+
(ert-deftest ruby-indent-simple ()
(ruby-should-indent-buffer
"if foo
console.log(num);
});
+ var z = [
+ ...iterableObj,
+ 4,
+ 5
+ ]
+
var arr = [
-1, 2,
-3, 4 +