diff options
| author | Mattias EngdegÄrd | 2020-06-21 21:04:30 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2020-06-22 09:51:11 +0200 |
| commit | 73daab99914b4972a7cd167b03102be4c68e83e5 (patch) | |
| tree | 454a7f5d3c33b72c1ba0b7f3cffb453473386c30 /lisp | |
| parent | ce4ec1793041ae0f013234ef7189ed855b5227a3 (diff) | |
| download | emacs-73daab99914b4972a7cd167b03102be4c68e83e5.tar.gz emacs-73daab99914b4972a7cd167b03102be4c68e83e5.zip | |
Preserve point in pascal-mode completion (bug#41740)
Failure to do so caused errors in several cases.
Reported by Shinichi Sakata.
* lisp/progmodes/pascal.el (pascal-type-completion)
(pascal-completion): Wrap code that may move point in save-excursion.
* test/lisp/progmodes/pascal-tests.el: New file.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/pascal.el | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el index 536a16dbb3c..b0191c029b9 100644 --- a/lisp/progmodes/pascal.el +++ b/lisp/progmodes/pascal.el | |||
| @@ -1170,26 +1170,27 @@ indent of the current line in parameterlist." | |||
| 1170 | 1170 | ||
| 1171 | (defun pascal-type-completion (pascal-str) | 1171 | (defun pascal-type-completion (pascal-str) |
| 1172 | "Calculate all possible completions for types." | 1172 | "Calculate all possible completions for types." |
| 1173 | (let ((start (point)) | 1173 | (save-excursion |
| 1174 | (pascal-all ()) | 1174 | (let ((start (point)) |
| 1175 | goon) | 1175 | (pascal-all ()) |
| 1176 | ;; Search for all reachable type declarations | 1176 | goon) |
| 1177 | (while (or (pascal-beg-of-defun) | 1177 | ;; Search for all reachable type declarations |
| 1178 | (setq goon (not goon))) | 1178 | (while (or (pascal-beg-of-defun) |
| 1179 | (save-excursion | 1179 | (setq goon (not goon))) |
| 1180 | (if (and (< start (prog1 (save-excursion (pascal-end-of-defun) | 1180 | (save-excursion |
| 1181 | (point)) | 1181 | (if (and (< start (prog1 (save-excursion (pascal-end-of-defun) |
| 1182 | (forward-char 1))) | 1182 | (point)) |
| 1183 | (re-search-forward | 1183 | (forward-char 1))) |
| 1184 | "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" | 1184 | (re-search-forward |
| 1185 | start t) | 1185 | "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" |
| 1186 | (not (match-end 1))) | 1186 | start t) |
| 1187 | ;; Check current type declaration | 1187 | (not (match-end 1))) |
| 1188 | (setq pascal-all | 1188 | ;; Check current type declaration |
| 1189 | (nconc (pascal-get-completion-decl pascal-str) | 1189 | (setq pascal-all |
| 1190 | pascal-all))))) | 1190 | (nconc (pascal-get-completion-decl pascal-str) |
| 1191 | pascal-all))))) | ||
| 1191 | 1192 | ||
| 1192 | pascal-all)) | 1193 | pascal-all))) |
| 1193 | 1194 | ||
| 1194 | (defun pascal-var-completion (prefix) | 1195 | (defun pascal-var-completion (prefix) |
| 1195 | "Calculate all possible completions for variables (or constants)." | 1196 | "Calculate all possible completions for variables (or constants)." |
| @@ -1263,11 +1264,13 @@ indent of the current line in parameterlist." | |||
| 1263 | (and (eq state 'defun) | 1264 | (and (eq state 'defun) |
| 1264 | (save-excursion | 1265 | (save-excursion |
| 1265 | (re-search-backward ")[ \t]*:" (point-at-bol) t)))) | 1266 | (re-search-backward ")[ \t]*:" (point-at-bol) t)))) |
| 1266 | (if (or (eq state 'paramlist) (eq state 'defun)) | 1267 | (save-excursion |
| 1267 | (pascal-beg-of-defun)) | 1268 | (if (or (eq state 'paramlist) (eq state 'defun)) |
| 1268 | (nconc | 1269 | (pascal-beg-of-defun)) |
| 1269 | (pascal-type-completion pascal-str) | 1270 | (nconc |
| 1270 | (pascal-keyword-completion pascal-type-keywords pascal-str))) | 1271 | (pascal-type-completion pascal-str) |
| 1272 | (pascal-keyword-completion pascal-type-keywords | ||
| 1273 | pascal-str)))) | ||
| 1271 | ( ;--Starting a new statement | 1274 | ( ;--Starting a new statement |
| 1272 | (and (not (eq state 'contexp)) | 1275 | (and (not (eq state 'contexp)) |
| 1273 | (save-excursion | 1276 | (save-excursion |