summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-engine.el4
-rw-r--r--lisp/progmodes/cc-langs.el5
-rw-r--r--lisp/progmodes/pascal.el53
-rw-r--r--lisp/progmodes/project.el50
4 files changed, 65 insertions, 47 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 8c8296fd6da..888184d2b46 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -3137,7 +3137,7 @@ comment at the start of cc-engine.el for more info."
(not base) ; FIXME!!! Compare base and far-base??
; (2019-05-21)
(not end)
- (> here end))
+ (>= here end))
(progn
(setq far-base-and-state (c-parse-ps-state-below here)
far-base (car far-base-and-state)
@@ -3150,7 +3150,7 @@ comment at the start of cc-engine.el for more info."
(or
(and (> here base) (null end))
(null (nth 8 s))
- (and end (> here end))
+ (and end (>= here end))
(not
(or
(and (nth 3 s) ; string
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 3ac4aad90b8..00babf95332 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2787,7 +2787,7 @@ Keywords here should also be in `c-block-stmt-1-kwds'."
java '("for" "if" "switch" "while" "catch" "synchronized")
idl nil
pike '("for" "if" "switch" "while" "foreach")
- awk '("for" "if" "while"))
+ awk '("for" "if" "switch" "while"))
(c-lang-defconst c-block-stmt-2-key
;; Regexp matching the start of any statement followed by a paren sexp
@@ -2867,8 +2867,7 @@ nevertheless contains a list separated with `;' and not `,'."
(c-lang-defconst c-case-kwds
"The keyword(s) which introduce a \"case\" like construct.
This construct is \"<keyword> <expression> :\"."
- t '("case")
- awk nil)
+ t '("case"))
(c-lang-defconst c-case-kwds-regexp
;; Adorned regexp matching any "case"-like keyword.
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index 536a16dbb3c..fce059bafc7 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -589,7 +589,7 @@ See also `pascal-comment-area'."
(interactive)
(catch 'found
(if (not (looking-at (concat "\\s \\|\\s)\\|" pascal-defun-re)))
- (forward-sexp 1))
+ (ignore-errors (forward-sexp 1)))
(let ((nest 0) (max -1) (func 0)
(reg (concat pascal-beg-block-re "\\|"
pascal-end-block-re "\\|"
@@ -1170,26 +1170,27 @@ indent of the current line in parameterlist."
(defun pascal-type-completion (pascal-str)
"Calculate all possible completions for types."
- (let ((start (point))
- (pascal-all ())
- goon)
- ;; Search for all reachable type declarations
- (while (or (pascal-beg-of-defun)
- (setq goon (not goon)))
- (save-excursion
- (if (and (< start (prog1 (save-excursion (pascal-end-of-defun)
- (point))
- (forward-char 1)))
- (re-search-forward
- "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>"
- start t)
- (not (match-end 1)))
- ;; Check current type declaration
- (setq pascal-all
- (nconc (pascal-get-completion-decl pascal-str)
- pascal-all)))))
+ (save-excursion
+ (let ((start (point))
+ (pascal-all ())
+ goon)
+ ;; Search for all reachable type declarations
+ (while (or (pascal-beg-of-defun)
+ (setq goon (not goon)))
+ (save-excursion
+ (if (and (< start (prog1 (save-excursion (pascal-end-of-defun)
+ (point))
+ (forward-char 1)))
+ (re-search-forward
+ "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>"
+ start t)
+ (not (match-end 1)))
+ ;; Check current type declaration
+ (setq pascal-all
+ (nconc (pascal-get-completion-decl pascal-str)
+ pascal-all)))))
- pascal-all))
+ pascal-all)))
(defun pascal-var-completion (prefix)
"Calculate all possible completions for variables (or constants)."
@@ -1263,11 +1264,13 @@ indent of the current line in parameterlist."
(and (eq state 'defun)
(save-excursion
(re-search-backward ")[ \t]*:" (point-at-bol) t))))
- (if (or (eq state 'paramlist) (eq state 'defun))
- (pascal-beg-of-defun))
- (nconc
- (pascal-type-completion pascal-str)
- (pascal-keyword-completion pascal-type-keywords pascal-str)))
+ (save-excursion
+ (if (or (eq state 'paramlist) (eq state 'defun))
+ (pascal-beg-of-defun))
+ (nconc
+ (pascal-type-completion pascal-str)
+ (pascal-keyword-completion pascal-type-keywords
+ pascal-str))))
( ;--Starting a new statement
(and (not (eq state 'contexp))
(save-excursion
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index bfbe2362721..0a15939d243 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -449,7 +449,7 @@ backend implementation of `project-external-roots'.")
(cl-defmethod project-ignores ((project (head vc)) dir)
(let* ((root (cdr project))
- backend)
+ backend)
(append
(when (file-equal-p dir root)
(setq backend (vc-responsible-backend root))
@@ -674,8 +674,8 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in
(let* ((all-files (project-files project dirs))
(completion-ignore-case read-file-name-completion-ignore-case)
(file (funcall project-read-file-name-function
- "Find file" all-files nil nil
- filename)))
+ "Find file" all-files nil nil
+ filename)))
(if (string= file "")
(user-error "You didn't specify the file")
(find-file file))))
@@ -719,7 +719,7 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in
If a buffer already exists for running a shell in the project's root,
switch to it. Otherwise, create a new shell buffer.
With \\[universal-argument] prefix arg, create a new inferior shell buffer even
-if one already exist."
+if one already exists."
(interactive)
(let* ((default-directory (project-root (project-current t)))
(default-project-shell-name
@@ -738,14 +738,15 @@ if one already exist."
If a buffer already exists for running Eshell in the project's root,
switch to it. Otherwise, create a new Eshell buffer.
With \\[universal-argument] prefix arg, create a new Eshell buffer even
-if one already exist."
+if one already exists."
(interactive)
+ (defvar eshell-buffer-name)
(let* ((default-directory (project-root (project-current t)))
(eshell-buffer-name
- (concat "*" (file-name-nondirectory
- (directory-file-name
- (file-name-directory default-directory)))
- "-eshell*"))
+ (concat "*" (file-name-nondirectory
+ (directory-file-name
+ (file-name-directory default-directory)))
+ "-eshell*"))
(eshell-buffer (get-buffer eshell-buffer-name)))
(if (and eshell-buffer (not current-prefix-arg))
(pop-to-buffer eshell-buffer)
@@ -809,7 +810,8 @@ is inside the directory hierarchy of the project's root."
(predicate
(lambda (buffer)
;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (and (not (eq (cdr buffer) current-buffer))
+ (and (cdr buffer)
+ (not (eq (cdr buffer) current-buffer))
(when-let ((file (buffer-local-value 'default-directory
(cdr buffer))))
(file-in-directory-p file root))))))
@@ -818,10 +820,10 @@ is inside the directory hierarchy of the project's root."
"Switch to buffer: "
(when (funcall predicate (cons other-name other-buffer))
other-name)
- t
+ nil
predicate))))
-(defcustom project-kill-buffers-skip-conditions
+(defcustom project-kill-buffers-ignores
'("\\*Help\\*")
"Conditions for buffers `project-kill-buffers' should not kill.
Each condition is either a regular expression matching a buffer
@@ -829,7 +831,8 @@ name, or a predicate function that takes a buffer object as
argument and returns non-nil if it matches. Buffers that match
any of the conditions will not be killed."
:type '(repeat (choice regexp function))
- :version "28.1")
+ :version "28.1"
+ :package-version '(project . "0.5.0"))
(defun project--buffer-list (pr)
"Return the list of all buffers in project PR."
@@ -845,7 +848,7 @@ any of the conditions will not be killed."
;;;###autoload
(defun project-kill-buffers ()
"Kill all live buffers belonging to the current project.
-Certain buffers may be \"spared\", see `project-kill-buffers-skip-conditions'."
+Certain buffers may be \"spared\", see `project-kill-buffers-ignores'."
(interactive)
(let ((pr (project-current t)) bufs)
(dolist (buf (project--buffer-list pr))
@@ -855,7 +858,7 @@ Certain buffers may be \"spared\", see `project-kill-buffers-skip-conditions'."
(string-match-p c (buffer-name buf)))
((functionp c)
(funcall c buf))))
- project-kill-buffers-skip-conditions)
+ project-kill-buffers-ignores)
(push buf bufs)))
(when (yes-or-no-p (format "Kill %d buffers in %s? "
(length bufs) (project-root pr)))
@@ -871,7 +874,8 @@ Certain buffers may be \"spared\", see `project-kill-buffers-skip-conditions'."
:group 'project)
(defvar project--list 'unset
- "List of known project directories.")
+ "List structure containing root directories of known projects.
+With some possible metadata (to be decided).")
(defun project--read-project-list ()
"Initialize `project--list' using contents of `project-list-file'."
@@ -880,7 +884,13 @@ Certain buffers may be \"spared\", see `project-kill-buffers-skip-conditions'."
(when (file-exists-p filename)
(with-temp-buffer
(insert-file-contents filename)
- (read (current-buffer)))))))
+ (read (current-buffer)))))
+ (unless (seq-every-p
+ (lambda (elt) (stringp (car-safe elt)))
+ project--list)
+ (warn "Contents of %s are in wrong format, resetting"
+ project-list-file)
+ (setq project--list nil))))
(defun project--ensure-read-project-list ()
"Initialize `project--list' if it isn't already initialized."
@@ -933,6 +943,12 @@ It's also possible to enter an arbitrary directory not in the list."
(read-directory-name "Select directory: " default-directory nil t)
pr-dir)))
+;;;###autoload
+(defun project-known-project-roots ()
+ "Return the list of root directories of all known projects."
+ (project--ensure-read-project-list)
+ (mapcar #'car project--list))
+
;;; Project switching