summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/authors.el4
-rw-r--r--lisp/emacs-lisp/bindat.el12
-rw-r--r--lisp/emacs-lisp/easy-mmode.el2
-rw-r--r--lisp/emacs-lisp/easymenu.el8
-rw-r--r--lisp/emacs-lisp/lisp.el103
-rw-r--r--lisp/emacs-lisp/syntax.el45
6 files changed, 99 insertions, 75 deletions
diff --git a/lisp/emacs-lisp/authors.el b/lisp/emacs-lisp/authors.el
index b9afebcb3ef..a19f054a468 100644
--- a/lisp/emacs-lisp/authors.el
+++ b/lisp/emacs-lisp/authors.el
@@ -75,7 +75,7 @@ files.")
(nil "(afs@hplb.hpl.hp.com)")
(nil "<Use-Author-Address-Header@\\[127.1\\]>")
(nil "Code Extracted")
- (nil "Fsf")
+ (nil "\\`FSF")
(nil "ISO-2022-JP")
("Jaeyoun Chung" "Jae-youn Chung" "Jae-you Chung" "Chung Jae-youn")
("Jan Dj,Ad(Brv" "Jan D." "Jan Djarv")
@@ -300,6 +300,8 @@ found) in the repository.")
("GETTING.GNU.SOFTWARE" . "FTP")
("leim-Makefile" . "leim/Makefile")
("leim-Makefile.in" . "leim/Makefile.in")
+ ("emacs-lisp/testcover-ses.el" . "tcover-ses.el")
+ ("emacs-lisp/testcover-unsafep.el" . "tcover-unsafep.el")
("INSTALL-CVS" . "INSTALL.CVS")
)
"Alist of files which have been renamed during their lifetime.
diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el
index 792272ef88a..6053fb3cf09 100644
--- a/lisp/emacs-lisp/bindat.el
+++ b/lisp/emacs-lisp/bindat.el
@@ -319,8 +319,8 @@
((eq type 'struct)
(setq data (bindat--unpack-group (eval len))))
((eq type 'repeat)
- (let ((index 0))
- (while (< index len)
+ (let ((index 0) (count len))
+ (while (< index count)
(setq data (cons (bindat--unpack-group (nthcdr tail item)) data))
(setq index (1+ index)))
(setq data (nreverse data))))
@@ -415,8 +415,8 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
(bindat--length-group
(if field (bindat-get-field struct field) struct) (eval len)))
((eq type 'repeat)
- (let ((index 0))
- (while (< index len)
+ (let ((index 0) (count len))
+ (while (< index count)
(bindat--length-group
(nth index (bindat-get-field struct field))
(nthcdr tail item))
@@ -559,8 +559,8 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
(bindat--pack-group
(if field (bindat-get-field struct field) struct) (eval len)))
((eq type 'repeat)
- (let ((index 0))
- (while (< index len)
+ (let ((index 0) (count len))
+ (while (< index count)
(bindat--pack-group
(nth index (bindat-get-field struct field))
(nthcdr tail item))
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index de8f0a91af4..213854edb54 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -274,7 +274,7 @@ With zero or negative ARG turn mode off.
(defalias 'easy-mmode-define-global-mode 'define-global-minor-mode)
;;;###autoload
(defmacro define-global-minor-mode (global-mode mode turn-on &rest keys)
- "Make GLOBAL-MODE out of the buffer-local minor MODE.
+ "Make a global mode GLOBAL-MODE corresponding to buffer-local minor MODE.
TURN-ON is a function that will be called with no args in every buffer
and that should try to turn MODE on if applicable for that buffer.
KEYS is a list of CL-style keyword arguments. As the minor mode
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index a2153beebd9..06cafb17e61 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -443,20 +443,24 @@ When non-nil, NOEXP indicates that CALLBACK cannot be an expression
command))
;;;###autoload
-(defun easy-menu-change (path name items &optional before)
+(defun easy-menu-change (path name items &optional before map)
"Change menu found at PATH as item NAME to contain ITEMS.
PATH is a list of strings for locating the menu that
should contain a submenu named NAME.
ITEMS is a list of menu items, as in `easy-menu-define'.
These items entirely replace the previous items in that submenu.
+If MAP is specified, it should normally be a keymap; nil stands for the local
+menu-bar keymap. It can also be a symbol, which has earlier been used as the
+first argument in a call to `easy-menu-define', or the value of such a symbol.
+
If the menu located by PATH has no submenu named NAME, add one.
If the optional argument BEFORE is present, add it just before
the submenu named BEFORE, otherwise add it at the end of the menu.
To implement dynamic menus, either call this from
`menu-bar-update-hook' or use a menu filter."
- (easy-menu-add-item nil path (easy-menu-create-menu name items) before))
+ (easy-menu-add-item map path (easy-menu-create-menu name items) before))
;; XEmacs needs the following two functions to add and remove menus.
;; In Emacs this is done automatically when switching keymaps, so
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 6e06e4a067b..895bec256d4 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -185,13 +185,18 @@ With ARG, do it that many times. Negative arg -N
means move forward to Nth following beginning of defun.
Returns t unless search stops due to beginning or end of buffer.
-Normally a defun starts when there is a char with open-parenthesis
-syntax at the beginning of a line. If `defun-prompt-regexp' is
-non-nil, then a string which matches that regexp may precede the
-open-parenthesis, and point ends up at the beginning of the line.
-
If variable `beginning-of-defun-function' is non-nil, its value
-is called as a function to find the defun's beginning."
+is called as a function to find the defun's beginning.
+
+Normally a defun is assumed to start where there is a char with
+open-parenthesis syntax at the beginning of a line. If
+`defun-prompt-regexp' is non-nil, then a string which matches
+that regexp may precede the open-parenthesis, and point ends up
+at the beginning of the line.
+
+If `defun-prompt-regexp' and `open-paren-in-column-0-is-defun-start'
+are both nil, the function instead finds an open-paren at the
+outermost level."
(interactive "p")
(or (not (eq this-command 'beginning-of-defun))
(eq last-command 'beginning-of-defun)
@@ -208,9 +213,9 @@ is non-nil.
If variable `beginning-of-defun-function' is non-nil, its value
is called as a function to find the defun's beginning."
- (interactive "p") ; change this to "P", maybe, if we ever come to pass ARG
- ; to beginning-of-defun-function.
- (unless arg (setq arg 1)) ; The call might not be interactive.
+ (interactive "p") ; change this to "P", maybe, if we ever come to pass ARG
+ ; to beginning-of-defun-function.
+ (unless arg (setq arg 1))
(cond
(beginning-of-defun-function
(if (> arg 0)
@@ -230,42 +235,56 @@ is called as a function to find the defun's beginning."
nil 'move arg)
(progn (goto-char (1- (match-end 0)))) t))
+ ;; If open-paren-in-column-0-is-defun-start and defun-prompt-regexp
+ ;; are both nil, column 0 has no significance - so scan forward
+ ;; from BOB to see how nested point is, then carry on from there.
+ ;;
+ ;; It is generally not a good idea to land up here, because the
+ ;; call to scan-lists below can be extremely slow. This is because
+ ;; back_comment in syntax.c may have to scan from bob to find the
+ ;; beginning of each comment. Fixing this is not trivial -- cyd.
+
+ ((eq arg 0))
(t
- ;; Column 0 has no significance - so scan forward from BOB to see how
- ;; nested point is, then carry on from there.
- (let* ((floor (point-min))
- (ceiling (point-max))
- (pps-state (let (syntax-begin-function
- font-lock-beginning-of-syntax-function)
- (syntax-ppss)))
- (nesting-depth (nth 0 pps-state)))
+ (let ((floor (point-min))
+ (ceiling (point-max))
+ (arg-+ve (> arg 0)))
(save-restriction
(widen)
- ;; Get outside of any string or comment.
- (if (nth 8 pps-state)
- (goto-char (nth 8 pps-state)))
-
- (cond
- ((> arg 0)
- (when (> nesting-depth 0)
- (up-list (- nesting-depth))
- (setq arg (1- arg)))
- ;; We're now outside of any defun.
- (backward-list arg)
- (if (< (point) floor) (goto-char floor)))
-
- ((< arg 0)
- (cond
- ((> nesting-depth 0)
- (up-list nesting-depth)
- (setq arg (1+ arg)))
- ((not (looking-at "\\s("))
- ;; We're between defuns, and not at the start of one.
- (setq arg (1+ arg))))
- (forward-list (- arg))
- (down-list)
- (backward-char)
- (if (> (point) ceiling) (goto-char ceiling)))))))))
+ (let ((ppss (let (syntax-begin-function
+ font-lock-beginning-of-syntax-function)
+ (syntax-ppss)))
+ ;; position of least enclosing paren, or nil.
+ encl-pos)
+ ;; Back out of any comment/string, so that encl-pos will always
+ ;; become nil if we're at top-level.
+ (when (nth 8 ppss)
+ (goto-char (nth 8 ppss))
+ (setq ppss (syntax-ppss))) ; should be fast, due to cache.
+ (setq encl-pos (syntax-ppss-toplevel-pos ppss))
+ (if encl-pos (goto-char encl-pos))
+
+ (and encl-pos arg-+ve (setq arg (1- arg)))
+ (and (not encl-pos) (not arg-+ve) (not (looking-at "\\s("))
+ (setq arg (1+ arg)))
+
+ (condition-case nil ; to catch crazy parens.
+ (progn
+ (goto-char (scan-lists (point) (- arg) 0))
+ (if arg-+ve
+ (if (>= (point) floor)
+ t
+ (goto-char floor)
+ nil)
+ ;; forward to next (, or trigger the c-c
+ (goto-char (1- (scan-lists (point) 1 -1)))
+ (if (<= (point) ceiling)
+ t
+ (goto-char ceiling)
+ nil)))
+ (error
+ (goto-char (if arg-+ve floor ceiling))
+ nil))))))))
(defvar end-of-defun-function nil
"If non-nil, function for function `end-of-defun' to call.
diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
index f290db42c04..0937076a7f4 100644
--- a/lisp/emacs-lisp/syntax.el
+++ b/lisp/emacs-lisp/syntax.el
@@ -53,12 +53,20 @@
(nth 0 ppss))
(defun syntax-ppss-toplevel-pos (ppss)
- "Return the last preceding position at toplevel.
-\"At toplevel\" means that it is outside of any syntactic entity:
-outside of any parentheses, or comments, or strings.
-Returns nil iff PPSS itself corresponds to a toplevel position."
+ "Get the latest syntactically outermost position found in a syntactic scan.
+PPSS is a scan state, as returned by `partial-parse-sexp' or `syntax-ppss'.
+An \"outermost position\" means one that it is outside of any syntactic entity:
+outside of any parentheses, comments, or strings encountered in the scan.
+If no such position is recorded in PPSS (because the end of the scan was
+itself at the outermost level), return nil."
+ ;; BEWARE! We rely on the undocumented 9th field. The 9th field currently
+ ;; contains the list of positions of the enclosing open-parens.
+ ;; I.e. those positions are outside of any string/comment and the first of
+ ;; those is outside of any paren (i.e. corresponds to a nil ppss).
+ ;; If this list is empty but we are in a string or comment, then the 8th
+ ;; field contains a similar "toplevel" position.
(or (car (nth 9 ppss))
- (nth 8 ppss)))
+ (nth 8 ppss)))
(defsubst syntax-ppss-context (ppss)
(cond
@@ -95,8 +103,7 @@ point (where the PPSS is equivalent to nil).")
;; depend on the text after BEG (which is presumably changed). So if
;; BEG=(car (nth 10 syntax-ppss-last)) don't reuse that data because the
;; assumed nil state at BEG may not be valid any more.
- (if (<= beg (or (car (nth 10 syntax-ppss-last))
- (nth 9 syntax-ppss-last)
+ (if (<= beg (or (syntax-ppss-toplevel-pos (cdr syntax-ppss-last))
(nth 3 syntax-ppss-last)
0))
(setq syntax-ppss-last nil)
@@ -144,22 +151,14 @@ Point is at POS when this function returns."
(cond
;; Use OLD-PPSS if possible and close enough.
((and (not old-pos) old-ppss
- ;; BEWARE! We rely on the undocumented 9th field. The 9th
- ;; field currently contains the list of positions of
- ;; open-parens of the enclosing parens. I.e. those
- ;; positions are outside of any string/comment
- ;; and the first of those is outside of any paren
- ;; (i.e. corresponds to a nil ppss). If this list is empty
- ;; but we are in a string or comment, then the 8th field
- ;; contains a similar "toplevel" position. If `pt-min' is
- ;; too far from `pos', we could try to use other positions
- ;; in (nth 9 old-ppss), but that doesn't seem to happen in
- ;; practice and it would complicate this code (and the
- ;; before-change-function code even more). But maybe it
- ;; would be useful in "degenerate" cases such as when the
- ;; whole file is wrapped in a set of parenthesis.
- (setq pt-min (or (car (nth 9 old-ppss))
- (nth 8 old-ppss)
+ ;; If `pt-min' is too far from `pos', we could try to use
+ ;; other positions in (nth 9 old-ppss), but that doesn't
+ ;; seem to happen in practice and it would complicate this
+ ;; code (and the before-change-function code even more).
+ ;; But maybe it would be useful in "degenerate" cases such
+ ;; as when the whole file is wrapped in a set
+ ;; of parentheses.
+ (setq pt-min (or (syntax-ppss-toplevel-pos old-ppss)
(nth 2 old-ppss)))
(<= pt-min pos) (< (- pos pt-min) syntax-ppss-max-span))
(incf (car (aref syntax-ppss-stats 1)))