summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/package.el6
-rw-r--r--lisp/emacs-lisp/regexp-opt.el43
-rw-r--r--lisp/progmodes/cc-engine.el58
-rw-r--r--lisp/progmodes/cc-langs.el36
-rw-r--r--lisp/progmodes/compile.el7
-rw-r--r--lisp/sort.el17
6 files changed, 62 insertions, 105 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index c4f751871b6..c91ee445e13 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2701,9 +2701,8 @@ either a full name or nil, and EMAIL is a valid email address."
["Help" package-menu-quick-help :help "Show short key binding help for package-menu-mode"]
"--"
["Refresh Package List" revert-buffer
- :help "Redownload the ELPA archive"
+ :help "Redownload the package archive(s)"
:active (not package--downloads-in-progress)]
- ["Redisplay buffer" revert-buffer :help "Update the buffer with current list of packages"]
["Execute Marked Actions" package-menu-execute :help "Perform all the marked actions"]
"--"
@@ -3197,7 +3196,8 @@ The default regexp will hide only the package whose name is at point."
(declare (interactive-only "change `package-hidden-regexps' instead."))
(let* ((name (when (derived-mode-p 'package-menu-mode)
(concat "\\`" (regexp-quote (symbol-name (package-desc-name
- (tabulated-list-get-id)))))))
+ (tabulated-list-get-id))))
+ "\\'")))
(re (read-string "Hide packages matching regexp: " name)))
;; Test if it is valid.
(string-match re "")
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index 2cce4e63539..35a5fda184f 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -84,7 +84,7 @@
;;; Code:
;;;###autoload
-(defun regexp-opt (strings &optional paren keep-order)
+(defun regexp-opt (strings &optional paren)
"Return a regexp to match a string in the list STRINGS.
Each member of STRINGS is treated as a fixed string, not as a regexp.
Optional PAREN specifies how the returned regexp is surrounded by
@@ -114,11 +114,8 @@ nil
necessary to ensure that a postfix operator appended to it will
apply to the whole expression.
-The optional argument KEEP-ORDER, if non-nil, forces the match to
-be performed in the order given, as if the strings were made into
-a regexp by joining them with the `\\|' operator. If nil or
-omitted, the returned regexp is will always match the longest
-string possible.
+The returned regexp is ordered in such a way that it will always
+match the longest string possible.
Up to reordering, the resulting regexp is equivalent to but
usually more efficient than that of a simplified version:
@@ -140,34 +137,12 @@ usually more efficient than that of a simplified version:
(completion-ignore-case nil)
(completion-regexp-list nil)
(open (cond ((stringp paren) paren) (paren "\\(")))
- (re
- (cond
- ;; No strings: return an unmatchable regexp.
- ((null strings)
- (concat (or open "\\(?:") regexp-unmatchable "\\)"))
-
- ;; The algorithm will generate a pattern that matches
- ;; longer strings in the list before shorter. If the
- ;; list order matters, then no string must come after a
- ;; proper prefix of that string. To check this, verify
- ;; that a straight or-pattern matches each string
- ;; entirely.
- ((and keep-order
- (let* ((case-fold-search nil)
- (alts (mapconcat #'regexp-quote strings "\\|")))
- (and (let ((s strings))
- (while (and s
- (string-match alts (car s))
- (= (match-end 0) (length (car s))))
- (setq s (cdr s)))
- ;; If we exited early, we found evidence that
- ;; regexp-opt-group cannot be used.
- s)
- (concat (or open "\\(?:") alts "\\)")))))
- (t
- (regexp-opt-group
- (delete-dups (sort (copy-sequence strings) 'string-lessp))
- (or open t) (not open))))))
+ (re (if strings
+ (regexp-opt-group
+ (delete-dups (sort (copy-sequence strings) 'string-lessp))
+ (or open t) (not open))
+ ;; No strings: return an unmatchable regexp.
+ (concat (or open "\\(?:") regexp-unmatchable "\\)"))))
(cond ((eq paren 'words)
(concat "\\<" re "\\>"))
((eq paren 'symbols)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 23fb1effdd4..0964c04b899 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -358,7 +358,8 @@ comment at the start of cc-engine.el for more info."
"Go to the end of a preprocessor directive.
More accurately, move the point to the end of the closest following
line that doesn't end with a line continuation backslash - no check is
-done that the point is inside a cpp directive to begin with.
+done that the point is inside a cpp directive to begin with, although
+it is assumed that point isn't inside a comment or string.
If LIM is provided, it is a limit position at which point is left
if the end of the macro doesn't occur earlier.
@@ -379,35 +380,32 @@ comment at the start of cc-engine.el for more info."
c-macro-cache-syntactic nil
c-macro-cache-no-comment nil))
(save-match-data
- (while
- (progn
- (while (progn
- (end-of-line)
- (when (and (eq (char-before) ?\\)
- (not (eobp)))
- (forward-char)
- t)))
- (let ((cand-EOM (point)))
- (if (and c-open-c-comment-on-logical-line-re
- (re-search-backward
- c-open-c-comment-on-logical-line-re
- nil t)
- (match-beginning 1)
- (progn
- (goto-char (match-beginning 1))
- (and (c-forward-single-comment)
- (> (point) cand-EOM))))
- t
- (goto-char cand-EOM)
- nil)))))
-
- (when (and (car c-macro-cache)
- (> (point) (car c-macro-cache)) ; in case we have a
- ; zero-sized region.
- (bolp)
- (not (eq (char-before (1- (point))) ?\\)))
- (setcdr c-macro-cache (point))
- (setq c-macro-cache-syntactic nil)))))
+ (let ((safe-pos (point))) ; a point ouside any literal.
+ ;; Move over stuff followed by a multiline block comment lacking
+ ;; escaped newlines each time around this loop.
+ (while
+ (progn
+ (while (progn
+ (end-of-line)
+ (when (and (eq (char-before) ?\\)
+ (not (eobp)))
+ (forward-char)
+ t)))
+ (let ((s (parse-partial-sexp safe-pos (point))))
+ (when ;; Are we in a block comment?
+ (and (nth 4 s) (not (nth 7 s)))
+ (progn
+ ;; Move to after the block comment.
+ (parse-partial-sexp
+ (point) (point-max) nil nil s 'syntax-table)
+ (setq safe-pos (point)))))))
+
+ (when (and (car c-macro-cache)
+ (> (point) (car c-macro-cache)) ; in case we have a
+ ; zero-sized region.
+ (not (eq (char-before (1- (point))) ?\\)))
+ (setcdr c-macro-cache (point))
+ (setq c-macro-cache-syntactic nil)))))))
(defun c-syntactic-end-of-macro ()
;; Go to the end of a CPP directive, or a "safe" pos just before.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 667561719cb..e7e7cfd4b09 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1706,32 +1706,16 @@ ender."
(c-lang-defvar c-last-c-comment-end-on-line-re
(c-lang-const c-last-c-comment-end-on-line-re))
-(c-lang-defconst c-last-open-c-comment-start-on-line-re
- "Do NOT use this constant any more. Instead use
-`c-open-c-comment-on-logical-line-re' (2020-02-10).
-
-Regexp which matches the last block comment start on the
-current ine, if any, or nil in those languages without block
-comments. When a match is found, submatch 1 contains the comment
-starter."
- t "\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
- awk nil)
-(c-lang-defvar c-last-open-c-comment-start-on-line-re
- (c-lang-const c-last-open-c-comment-start-on-line-re))
-(make-obsolete-variable 'c-last-open-c-comment-start-on-line-re
- 'c-open-c-comment-on-logical-line-re
- "5.35")
-
-(c-lang-defconst c-open-c-comment-on-logical-line-re
- "Regexp which matches an open block comment on the current logical line.
-It is intended for searching backwards from the end of a line.
-Such a search will stop at the first encountered non-escaped
-newline or open block comment. If the comment is found, submatch
-1 contains the comment starter."
-t "[^\\\n][\r\n]\\|\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
-awk nil)
-(c-lang-defvar c-open-c-comment-on-logical-line-re
- (c-lang-const c-open-c-comment-on-logical-line-re))
+;; The following is no longer used (2020-02-16).
+;; (c-lang-defconst c-last-open-c-comment-start-on-line-re
+;; "Regexp which matches the last block comment start on the
+;; current ine, if any, or nil in those languages without block
+;; comments. When a match is found, submatch 1 contains the comment
+;; starter."
+;; t "\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
+;; awk nil)
+;; (c-lang-defvar c-last-open-c-comment-start-on-line-re
+;; (c-lang-const c-last-open-c-comment-start-on-line-re))
(c-lang-defconst c-literal-start-regexp
;; Regexp to match the start of comments and string literals.
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index a7350f42c24..48ac85a73b7 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -391,13 +391,6 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
(mips-2
" in \\([^()\n ]+\\)(\\([0-9]+\\))$" 1 2)
- (msft
- ;; The message may be a "warning", "error", or "fatal error" with
- ;; an error code, or "see declaration of" without an error code.
- "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
-: \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
- 2 3 nil (4))
-
(omake
;; "omake -P" reports "file foo changed"
;; (useful if you do "cvs up" and want to see what has changed)
diff --git a/lisp/sort.el b/lisp/sort.el
index 40347e6a8b2..e4ff2afb3d7 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -544,23 +544,30 @@ Use \\[untabify] to convert tabs to spaces before sorting."
;;;###autoload
(defun reverse-region (beg end)
"Reverse the order of lines in a region.
-From a program takes two point or marker arguments, BEG and END."
+When called from Lisp, takes two point or marker arguments, BEG and END.
+If BEG is not at the beginning of a line, the first line of those
+to be reversed is the line starting after BEG.
+If END is not at the end of a line, the last line to be reversed
+is the one that ends before END."
(interactive "r")
(if (> beg end)
(let (mid) (setq mid end end beg beg mid)))
(save-excursion
- ;; put beg at the start of a line and end and the end of one --
- ;; the largest possible region which fits this criteria
+ (when (or (< (line-beginning-position) beg)
+ (< end (line-end-position)))
+ (user-error "There are no full lines in the region"))
+ ;; Put beg at the start of a line and end and the end of one --
+ ;; the largest possible region which fits this criteria.
(goto-char beg)
(or (bolp) (forward-line 1))
(setq beg (point))
(goto-char end)
- ;; the test for bolp is for those times when end is on an empty line;
+ ;; The test for bolp is for those times when end is on an empty line;
;; it is probably not the case that the line should be included in the
;; reversal; it isn't difficult to add it afterward.
(or (and (eolp) (not (bolp))) (progn (forward-line -1) (end-of-line)))
(setq end (point-marker))
- ;; the real work. this thing cranks through memory on large regions.
+ ;; The real work. This thing cranks through memory on large regions.
(let (ll (do t))
(while do
(goto-char beg)