diff options
| author | Stefan Monnier | 2002-04-09 18:56:34 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-04-09 18:56:34 +0000 |
| commit | da2a1edf5b6286e186d440ca3ede0356cebdd2ed (patch) | |
| tree | 6abf2c96f50f20bb3855f92b1b7eb3d00b71bfb6 /lisp/progmodes | |
| parent | 18f9934c8ae5605913f2707d12fe1ee80cfa4127 (diff) | |
| download | emacs-da2a1edf5b6286e186d440ca3ede0356cebdd2ed.tar.gz emacs-da2a1edf5b6286e186d440ca3ede0356cebdd2ed.zip | |
Add support for the new project file fields:
gnatfind-opt, debug-pre-cmd and debug-post-cmd. Fix widget handling
for Emacs 21. ada-mode now only supports a single active project file,
instead of one per buffer. This is far less confusing.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/ada-prj.el | 223 |
1 files changed, 135 insertions, 88 deletions
diff --git a/lisp/progmodes/ada-prj.el b/lisp/progmodes/ada-prj.el index d6ded072a0d..a3f4027e9e7 100644 --- a/lisp/progmodes/ada-prj.el +++ b/lisp/progmodes/ada-prj.el | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | ;;; ada-prj.el --- easy editing of project files for the ada-mode | 1 | ;;; ada-prj.el --- easy editing of project files for the ada-mode |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1998, 1999 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998, 99, 2000, 2001 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Emmanuel Briot <briot@gnat.com> | 5 | ;; Author: Emmanuel Briot <briot@gnat.com> |
| 6 | ;; Ada Core Technologies's version: $Revision: 1.6 $ | 6 | ;; Ada Core Technologies's version: $Revision: 1.53 $ |
| 7 | ;; Keywords: languages, ada, project file | 7 | ;; Keywords: languages, ada, project file |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| @@ -53,6 +53,9 @@ | |||
| 53 | (defvar ada-prj-ada-buffer nil | 53 | (defvar ada-prj-ada-buffer nil |
| 54 | "Indicates what Ada source file was being edited.") | 54 | "Indicates what Ada source file was being edited.") |
| 55 | 55 | ||
| 56 | (defvar ada-old-cross-prefix nil | ||
| 57 | "The cross-prefix associated with the currently loaded runtime library.") | ||
| 58 | |||
| 56 | 59 | ||
| 57 | ;; ----- Functions -------------------------------------------------------- | 60 | ;; ----- Functions -------------------------------------------------------- |
| 58 | 61 | ||
| @@ -60,8 +63,9 @@ | |||
| 60 | "Open a new project file" | 63 | "Open a new project file" |
| 61 | (interactive) | 64 | (interactive) |
| 62 | (let* ((prj | 65 | (let* ((prj |
| 63 | (if (my-local-variable-if-set-p 'ada-prj-prj-file (current-buffer)) | 66 | (if (and ada-prj-default-project-file |
| 64 | ada-prj-prj-file | 67 | (not (string= ada-prj-default-project-file ""))) |
| 68 | ada-prj-default-project-file | ||
| 65 | "default.adp")) | 69 | "default.adp")) |
| 66 | (filename (read-file-name "Project file: " | 70 | (filename (read-file-name "Project file: " |
| 67 | (if prj "" nil) | 71 | (if prj "" nil) |
| @@ -84,23 +88,6 @@ If there is none, opens a new project file" | |||
| 84 | (ada-customize)) | 88 | (ada-customize)) |
| 85 | (ada-prj-new)))) | 89 | (ada-prj-new)))) |
| 86 | 90 | ||
| 87 | (defun ada-prj-add-ada-menu () | ||
| 88 | "Add a new submenu to the Ada menu. | ||
| 89 | The items are added to the menu NAME in map MAP. NAME should be the same | ||
| 90 | name as was passed to `ada-create-menu'." | ||
| 91 | (if ada-xemacs | ||
| 92 | (progn | ||
| 93 | (funcall (symbol-function 'add-menu-button) | ||
| 94 | '("Ada" "Project") | ||
| 95 | ["Edit" ada-prj-edit t] "Associate") | ||
| 96 | (funcall (symbol-function 'add-menu-button) | ||
| 97 | '("Ada" "Project") | ||
| 98 | ["New..." ada-prj-new t] "Associate")) | ||
| 99 | (define-key (lookup-key ada-mode-map [menu-bar Ada Project]) | ||
| 100 | [Edit] '("Edit current" . ada-prj-edit)) | ||
| 101 | (define-key (lookup-key ada-mode-map [menu-bar Ada Project]) | ||
| 102 | [New] '("New" . ada-prj-new)))) | ||
| 103 | |||
| 104 | (defun ada-prj-add-keymap () | 91 | (defun ada-prj-add-keymap () |
| 105 | "Add new keybindings for ada-prj." | 92 | "Add new keybindings for ada-prj." |
| 106 | (define-key ada-mode-map "\C-cu" 'ada-prj-edit)) | 93 | (define-key ada-mode-map "\C-cu" 'ada-prj-edit)) |
| @@ -117,10 +104,8 @@ project file is found, returns the default values." | |||
| 117 | (if (file-exists-p filename) | 104 | (if (file-exists-p filename) |
| 118 | (ada-reread-prj-file)) | 105 | (ada-reread-prj-file)) |
| 119 | 106 | ||
| 120 | ;; Else use the one from the current buffer | 107 | ;; Else use the active one |
| 121 | (save-excursion | 108 | (set 'prj ada-prj-default-project-file)) |
| 122 | (set-buffer ada-buffer) | ||
| 123 | (set 'prj ada-prj-prj-file))) | ||
| 124 | 109 | ||
| 125 | 110 | ||
| 126 | (if (and prj | 111 | (if (and prj |
| @@ -160,25 +145,35 @@ If the current value of FIELD is the default value, returns an empty string." | |||
| 160 | (ada-prj-save-specific-option 'bind_opt) | 145 | (ada-prj-save-specific-option 'bind_opt) |
| 161 | (ada-prj-save-specific-option 'link_opt) | 146 | (ada-prj-save-specific-option 'link_opt) |
| 162 | (ada-prj-save-specific-option 'gnatmake_opt) | 147 | (ada-prj-save-specific-option 'gnatmake_opt) |
| 148 | (ada-prj-save-specific-option 'gnatfind_opt) | ||
| 163 | (ada-prj-save-specific-option 'cross_prefix) | 149 | (ada-prj-save-specific-option 'cross_prefix) |
| 164 | (ada-prj-save-specific-option 'remote_machine) | 150 | (ada-prj-save-specific-option 'remote_machine) |
| 165 | (ada-prj-save-specific-option 'comp_cmd) | ||
| 166 | (ada-prj-save-specific-option 'check_cmd) | ||
| 167 | (ada-prj-save-specific-option 'make_cmd) | ||
| 168 | (ada-prj-save-specific-option 'run_cmd) | ||
| 169 | (ada-prj-save-specific-option 'debug_cmd) | 151 | (ada-prj-save-specific-option 'debug_cmd) |
| 170 | 152 | ||
| 171 | ;; Always save the fields that depend on the current buffer | 153 | ;; Always save the fields that depend on the current buffer |
| 172 | (concat "main=" (plist-get ada-prj-current-values 'main) "\n") | 154 | "main=" (plist-get ada-prj-current-values 'main) "\n" |
| 173 | (concat "main_unit=" (plist-get ada-prj-current-values 'main_unit) "\n") | 155 | "main_unit=" (plist-get ada-prj-current-values 'main_unit) "\n" |
| 174 | (concat "build_dir=" (plist-get ada-prj-current-values 'build_dir) "\n") | 156 | "build_dir=" (plist-get ada-prj-current-values 'build_dir) "\n" |
| 175 | 157 | (ada-prj-set-list "check_cmd" | |
| 176 | (ada-prj-set-list "casing" | 158 | (plist-get ada-prj-current-values 'check_cmd)) "\n" |
| 177 | (plist-get ada-prj-current-values 'casing)) "\n" | 159 | (ada-prj-set-list "make_cmd" |
| 160 | (plist-get ada-prj-current-values 'make_cmd)) "\n" | ||
| 161 | (ada-prj-set-list "comp_cmd" | ||
| 162 | (plist-get ada-prj-current-values 'comp_cmd)) "\n" | ||
| 163 | (ada-prj-set-list "run_cmd" | ||
| 164 | (plist-get ada-prj-current-values 'run_cmd)) "\n" | ||
| 178 | (ada-prj-set-list "src_dir" | 165 | (ada-prj-set-list "src_dir" |
| 179 | (plist-get ada-prj-current-values 'src_dir)) "\n" | 166 | (plist-get ada-prj-current-values 'src_dir) |
| 167 | t) "\n" | ||
| 180 | (ada-prj-set-list "obj_dir" | 168 | (ada-prj-set-list "obj_dir" |
| 181 | (plist-get ada-prj-current-values 'obj_dir)) "\n" | 169 | (plist-get ada-prj-current-values 'obj_dir) |
| 170 | t) "\n" | ||
| 171 | (ada-prj-set-list "debug_pre_cmd" | ||
| 172 | (plist-get ada-prj-current-values 'debug_pre_cmd)) | ||
| 173 | "\n" | ||
| 174 | (ada-prj-set-list "debug_post_cmd" | ||
| 175 | (plist-get ada-prj-current-values 'debug_post_cmd)) | ||
| 176 | "\n" | ||
| 182 | )) | 177 | )) |
| 183 | 178 | ||
| 184 | (find-file file-name) | 179 | (find-file file-name) |
| @@ -191,9 +186,8 @@ If the current value of FIELD is the default value, returns an empty string." | |||
| 191 | ;; kill the editor buffer | 186 | ;; kill the editor buffer |
| 192 | (kill-buffer "*Customize Ada Mode*") | 187 | (kill-buffer "*Customize Ada Mode*") |
| 193 | 188 | ||
| 194 | ;; automatically associates the current buffer with the | 189 | ;; automatically set the new project file as the active one |
| 195 | ;; new project file | 190 | (set 'ada-prj-default-project-file file-name) |
| 196 | (set (make-local-variable 'ada-prj-prj-file) file-name) | ||
| 197 | 191 | ||
| 198 | ;; force Emacs to reread the project files | 192 | ;; force Emacs to reread the project files |
| 199 | (ada-reread-prj-file file-name) | 193 | (ada-reread-prj-file file-name) |
| @@ -261,10 +255,18 @@ The current buffer must be the project editing buffer." | |||
| 261 | (let ((inhibit-read-only t)) | 255 | (let ((inhibit-read-only t)) |
| 262 | (erase-buffer)) | 256 | (erase-buffer)) |
| 263 | 257 | ||
| 258 | ;; Widget support in Emacs 21 requires that we clear the buffer first | ||
| 259 | (if (and (not (boundp 'running-xemacs)) (>= emacs-major-version 21)) | ||
| 260 | (progn | ||
| 261 | (setq widget-field-new nil | ||
| 262 | widget-field-list nil) | ||
| 263 | (mapcar (lambda (x) (delete-overlay x)) (car (overlay-lists))) | ||
| 264 | (mapcar (lambda (x) (delete-overlay x)) (cdr (overlay-lists))))) | ||
| 265 | |||
| 264 | ;; Display the tabs | 266 | ;; Display the tabs |
| 265 | 267 | ||
| 266 | (widget-insert "\n Project and Editor configuration.\n | 268 | (widget-insert "\n Project and Editor configuration.\n |
| 267 | ___________ ____________ ____________ ____________\n / ") | 269 | ___________ ____________ ____________ ____________ ____________\n / ") |
| 268 | (widget-create 'push-button :notify | 270 | (widget-create 'push-button :notify |
| 269 | (lambda (&rest dummy) (ada-prj-display-page 1)) "General") | 271 | (lambda (&rest dummy) (ada-prj-display-page 1)) "General") |
| 270 | (widget-insert " \\ / ") | 272 | (widget-insert " \\ / ") |
| @@ -276,6 +278,9 @@ The current buffer must be the project editing buffer." | |||
| 276 | (widget-insert " \\ / ") | 278 | (widget-insert " \\ / ") |
| 277 | (widget-create 'push-button :notify | 279 | (widget-create 'push-button :notify |
| 278 | (lambda (&rest dummy) (ada-prj-display-page 4)) "Ada Menu") | 280 | (lambda (&rest dummy) (ada-prj-display-page 4)) "Ada Menu") |
| 281 | (widget-insert " \\ / ") | ||
| 282 | (widget-create 'push-button :notify | ||
| 283 | (lambda (&rest dummy) (ada-prj-display-page 5)) "Debugger") | ||
| 279 | (widget-insert " \\\n") | 284 | (widget-insert " \\\n") |
| 280 | 285 | ||
| 281 | ;; Display the currently selected page | 286 | ;; Display the currently selected page |
| @@ -286,7 +291,7 @@ The current buffer must be the project editing buffer." | |||
| 286 | ;; First page (General) | 291 | ;; First page (General) |
| 287 | ;; | 292 | ;; |
| 288 | ((= tab-num 1) | 293 | ((= tab-num 1) |
| 289 | (widget-insert "_/ \\/______________\\/______________\\/______________\\_____\n\n") | 294 | (widget-insert "/ \\/______________\\/______________\\/______________\\/______________\\\n") |
| 290 | 295 | ||
| 291 | (widget-insert "Project file name:\n") | 296 | (widget-insert "Project file name:\n") |
| 292 | (widget-insert (plist-get ada-prj-current-values 'filename)) | 297 | (widget-insert (plist-get ada-prj-current-values 'filename)) |
| @@ -333,7 +338,15 @@ To use JGNAT, enter 'j'.") | |||
| 333 | ;; Second page (Paths) | 338 | ;; Second page (Paths) |
| 334 | ;; | 339 | ;; |
| 335 | ((= tab-num 2) | 340 | ((= tab-num 2) |
| 336 | (widget-insert "_/_____________\\/ \\/______________\\/______________\\_____\n\n") | 341 | (if (not (equal (plist-get ada-prj-current-values 'cross_prefix) |
| 342 | ada-old-cross-prefix)) | ||
| 343 | (progn | ||
| 344 | (setq ada-old-cross-prefix | ||
| 345 | (plist-get ada-prj-current-values 'cross_prefix)) | ||
| 346 | (ada-initialize-runtime-library ada-old-cross-prefix))) | ||
| 347 | |||
| 348 | |||
| 349 | (widget-insert "/_____________\\/ \\/______________\\/______________\\/______________\\\n") | ||
| 337 | (ada-prj-field 'src_dir "Source directories" | 350 | (ada-prj-field 'src_dir "Source directories" |
| 338 | "Enter the list of directories where your Ada | 351 | "Enter the list of directories where your Ada |
| 339 | sources can be found. These directories will be | 352 | sources can be found. These directories will be |
| @@ -343,9 +356,9 @@ Note that src_dir includes both the build directory | |||
| 343 | and the standard runtime." | 356 | and the standard runtime." |
| 344 | t t | 357 | t t |
| 345 | (mapconcat (lambda(x) | 358 | (mapconcat (lambda(x) |
| 346 | (concat " " x)) | 359 | (concat " " x)) |
| 347 | ada-xref-runtime-library-specs-path | 360 | ada-xref-runtime-library-specs-path |
| 348 | "\n") | 361 | "\n") |
| 349 | ) | 362 | ) |
| 350 | (widget-insert "\n\n") | 363 | (widget-insert "\n\n") |
| 351 | 364 | ||
| @@ -358,9 +371,9 @@ Note that obj_dir includes both the build directory | |||
| 358 | and the standard runtime." | 371 | and the standard runtime." |
| 359 | t t | 372 | t t |
| 360 | (mapconcat (lambda(x) | 373 | (mapconcat (lambda(x) |
| 361 | (concat " " x)) | 374 | (concat " " x)) |
| 362 | ada-xref-runtime-library-ali-path | 375 | ada-xref-runtime-library-ali-path |
| 363 | "\n") | 376 | "\n") |
| 364 | ) | 377 | ) |
| 365 | (widget-insert "\n\n") | 378 | (widget-insert "\n\n") |
| 366 | ) | 379 | ) |
| @@ -369,7 +382,7 @@ and the standard runtime." | |||
| 369 | ;; Third page (Switches) | 382 | ;; Third page (Switches) |
| 370 | ;; | 383 | ;; |
| 371 | ((= tab-num 3) | 384 | ((= tab-num 3) |
| 372 | (widget-insert "_/_____________\\/______________\\/ \\/______________\\_____\n\n") | 385 | (widget-insert "/_____________\\/______________\\/ \\/______________\\/______________\\\n") |
| 373 | (ada-prj-field 'comp_opt "Switches for the compiler" | 386 | (ada-prj-field 'comp_opt "Switches for the compiler" |
| 374 | "These switches are used in the default | 387 | "These switches are used in the default |
| 375 | compilation commands, both for compiling a | 388 | compilation commands, both for compiling a |
| @@ -383,56 +396,78 @@ command and are passed to the linker") | |||
| 383 | (ada-prj-field 'gnatmake_opt "Switches for gnatmake" | 396 | (ada-prj-field 'gnatmake_opt "Switches for gnatmake" |
| 384 | "These switches are used in the default gnatmake | 397 | "These switches are used in the default gnatmake |
| 385 | command.") | 398 | command.") |
| 399 | (ada-prj-field 'gnatfind_opt "Switches for gnatfind" | ||
| 400 | "The command gnatfind is run every time the Ada/Goto/List_References menu. | ||
| 401 | You should for instance add -a if you are working in an environment | ||
| 402 | where most ALI files are write-protected, since otherwise they get | ||
| 403 | ignored by gnatfind and you don't see the references within.") | ||
| 386 | ) | 404 | ) |
| 387 | 405 | ||
| 388 | ;; | 406 | ;; |
| 389 | ;; Fourth page | 407 | ;; Fourth page |
| 390 | ;; | 408 | ;; |
| 391 | ((= tab-num 4) | 409 | ((= tab-num 4) |
| 392 | (widget-insert "_/_____________\\/______________\\/______________\\/ \\_____\n\n") | 410 | (widget-insert "/_____________\\/______________\\/______________\\/ \\/______________\\\n") |
| 393 | (widget-insert "All the fields below can use variable substitution\n") | ||
| 394 | (widget-insert "The syntax is ${name}, where name is the name that\n") | ||
| 395 | (widget-insert "appears after the Help buttons in this buffer.\n") | ||
| 396 | (widget-insert "As a special case, ${current} is replaced with the name\n") | ||
| 397 | (widget-insert "of the file currently edited, with directory name but\n") | ||
| 398 | (widget-insert "no extension.\n\n") | ||
| 399 | (widget-insert | ||
| 400 | "The environment variables ADA_INCLUDE_PATH and ADA_OBJECTS_PATH\n") | ||
| 401 | (widget-insert | 411 | (widget-insert |
| 402 | "are set to ${src_dir} and ${obj_dir} before running the compilation\n") | 412 | "All the fields below can use variable substitution The syntax is ${name}, |
| 413 | where name is the name that appears after the Help buttons in this buffer. As | ||
| 414 | a special case, ${current} is replaced with the name of the file currently | ||
| 415 | edited, with directory name but no extension, whereas ${full_current} is | ||
| 416 | replaced with the name of the current file with directory name and | ||
| 417 | extension.\n") | ||
| 403 | (widget-insert | 418 | (widget-insert |
| 404 | "commands, so that you don't need to specify the -aI and -aO\n") | 419 | "The environment variables ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are set to |
| 420 | ${src_dir} and ${obj_dir} before running the compilation commands, so that you | ||
| 421 | don't need to specify the -aI and -aO switches on the command line\n") | ||
| 405 | (widget-insert | 422 | (widget-insert |
| 406 | "switches on the command line\n\n") | 423 | "You can reference any environment variable using the same ${...} syntax as |
| 407 | 424 | above, and put the name of the variable between the quotes.\n\n") | |
| 408 | (ada-prj-field 'check_cmd | 425 | (ada-prj-field 'check_cmd |
| 409 | "Check syntax of a single file (menu Ada->Check File)" | 426 | "Check syntax of a single file (menu Ada->Check File)" |
| 410 | "This command is run to check the syntax and semantics of a file. | 427 | "This command is run to check the syntax and semantics of a file. |
| 411 | The file name is added at the end of this command.") | 428 | The file name is added at the end of this command." t) |
| 412 | (ada-prj-field 'comp_cmd | 429 | (ada-prj-field 'comp_cmd |
| 413 | "Compiling a single file (menu Ada->Compile File)" | 430 | "Compiling a single file (menu Ada->Compile File)" |
| 414 | "This command is run when the recompilation | 431 | "This command is run when the recompilation |
| 415 | of a single file is needed. The file name is | 432 | of a single file is needed. The file name is |
| 416 | added at the end of this command.") | 433 | added at the end of this command." t) |
| 417 | (ada-prj-field 'make_cmd "Rebuilding the whole project (menu Ada->Build)" | 434 | (ada-prj-field 'make_cmd "Rebuilding the whole project (menu Ada->Build)" |
| 418 | "This command is run when you want to rebuild | 435 | "This command is run when you want to rebuild |
| 419 | your whole application. It is never issues | 436 | your whole application. It is never issues |
| 420 | automatically and you will need to ask for it. | 437 | automatically and you will need to ask for it. |
| 421 | If remote_machine has been set, this command | 438 | If remote_machine has been set, this command |
| 422 | will be executed on the remote machine.") | 439 | will be executed on the remote machine." t) |
| 423 | (ada-prj-field 'run_cmd "Running the application (menu Ada->Run)" | 440 | (ada-prj-field 'run_cmd "Running the application (menu Ada->Run)" |
| 424 | "This command specifies how to run the | 441 | "This command specifies how to run the |
| 425 | application, including any switch you need to | 442 | application, including any switch you need to |
| 426 | specify. If remote_machine has been set, this | 443 | specify. If remote_machine has been set, this |
| 427 | command will be executed on the remote host.") | 444 | command will be executed on the remote host." t) |
| 445 | ) | ||
| 446 | |||
| 447 | ;; | ||
| 448 | ;; Fifth page | ||
| 449 | ;; | ||
| 450 | ((= tab-num 5) | ||
| 451 | (widget-insert "/_____________\\/______________\\/______________\\/______________\\/ \\\n") | ||
| 452 | (ada-prj-field 'debug_pre_cmd "Commands to execute before launching the | ||
| 453 | debugger" | ||
| 454 | "The following commands are executed one after the other before starting | ||
| 455 | the debugger. These can be used to set up your environment." t) | ||
| 456 | |||
| 428 | (ada-prj-field 'debug_cmd "Debugging the application" | 457 | (ada-prj-field 'debug_cmd "Debugging the application" |
| 429 | "Specifies how to debug the application, possibly | 458 | "Specifies how to debug the application, possibly |
| 430 | remotely if remote_machine has been set. We | 459 | remotely if remote_machine has been set. We |
| 431 | recommend the following debuggers: | 460 | recommend the following debuggers: |
| 432 | > gdb | 461 | > gdb |
| 433 | > gdbtk | 462 | > gvd --tty |
| 434 | > ddd --tty -fullname -toolbar") | 463 | > ddd --tty -fullname -toolbar") |
| 464 | |||
| 465 | (ada-prj-field 'debug_post_cmd "Commands to execute in the debugger" | ||
| 466 | "The following commands are executed one in the debugger once it has been | ||
| 467 | started. These can be used to initialize the debugger, for instance to | ||
| 468 | connect to the target when working with cross-environments" t) | ||
| 435 | ) | 469 | ) |
| 470 | |||
| 436 | ) | 471 | ) |
| 437 | 472 | ||
| 438 | 473 | ||
| @@ -481,16 +516,25 @@ If FILENAME is given, edit that file." | |||
| 481 | (make-local-variable 'widget-keymap) | 516 | (make-local-variable 'widget-keymap) |
| 482 | (define-key widget-keymap "\C-x\C-s" 'ada-prj-save) | 517 | (define-key widget-keymap "\C-x\C-s" 'ada-prj-save) |
| 483 | 518 | ||
| 519 | (set (make-local-variable 'ada-old-cross-prefix) | ||
| 520 | (ada-xref-get-project-field 'cross-prefix)) | ||
| 521 | |||
| 484 | (ada-prj-display-page 1) | 522 | (ada-prj-display-page 1) |
| 485 | )) | 523 | )) |
| 486 | 524 | ||
| 487 | ;; ---------------- Utilities -------------------------------- | 525 | ;; ---------------- Utilities -------------------------------- |
| 488 | 526 | ||
| 489 | (defun ada-prj-set-list (string ada-dir-list) | 527 | (defun ada-prj-set-list (string ada-list &optional is-directory) |
| 490 | "Join the strings in ADA-DIR-LIST into a single string. Each name is put | 528 | "Join the strings in ADA-LIST into a single string. |
| 491 | on a separate line that begins with STRING." | 529 | Each name is put on a separate line that begins with STRING. |
| 492 | (mapconcat (lambda (x) (concat string "=" (file-name-as-directory x))) | 530 | If IS-DIRECTORY is non-nil, each name is explicitly converted to a |
| 493 | ada-dir-list "\n")) | 531 | directory name." |
| 532 | |||
| 533 | (mapconcat (lambda (x) (concat string "=" | ||
| 534 | (if is-directory | ||
| 535 | (file-name-as-directory x) | ||
| 536 | x))) | ||
| 537 | ada-list "\n")) | ||
| 494 | 538 | ||
| 495 | 539 | ||
| 496 | (defun ada-prj-get-prj-dir (&optional ada-file) | 540 | (defun ada-prj-get-prj-dir (&optional ada-file) |
| @@ -518,7 +562,7 @@ change in ada-prj-current-values so that selecting another page and coming | |||
| 518 | back keeps the new value." | 562 | back keeps the new value." |
| 519 | (set 'ada-prj-current-values | 563 | (set 'ada-prj-current-values |
| 520 | (plist-put ada-prj-current-values | 564 | (plist-put ada-prj-current-values |
| 521 | (widget-get widget 'prj-field) | 565 | (widget-get widget ':prj-field) |
| 522 | (widget-value widget)))) | 566 | (widget-value widget)))) |
| 523 | 567 | ||
| 524 | (defun ada-prj-display-help (widget widget-modified event) | 568 | (defun ada-prj-display-help (widget widget-modified event) |
| @@ -539,15 +583,17 @@ this function can be used as :notify for the widget." | |||
| 539 | ))) | 583 | ))) |
| 540 | 584 | ||
| 541 | (defun ada-prj-show-value (widget widget-modified event) | 585 | (defun ada-prj-show-value (widget widget-modified event) |
| 542 | (let ((value (plist-get ada-prj-current-values | 586 | (let* ((field (widget-get widget ':prj-field)) |
| 543 | (widget-get widget 'prj-field))) | 587 | (value (plist-get ada-prj-current-values field)) |
| 544 | (inhibit-read-only t)) | 588 | (inhibit-read-only t) |
| 589 | w) | ||
| 545 | 590 | ||
| 546 | ;; If the other widget is already visible, delete it | 591 | ;; If the other widget is already visible, delete it |
| 547 | (if (widget-get widget 'prj-other-widget) | 592 | (if (widget-get widget 'prj-other-widget) |
| 548 | (progn | 593 | (progn |
| 549 | (widget-delete (widget-get widget 'prj-other-widget)) | 594 | (widget-delete (widget-get widget 'prj-other-widget)) |
| 550 | (widget-put widget 'prj-other-widget nil) | 595 | (widget-put widget 'prj-other-widget nil) |
| 596 | (widget-put widget ':prj-field field) | ||
| 551 | (widget-default-value-set widget "Show Value") | 597 | (widget-default-value-set widget "Show Value") |
| 552 | ) | 598 | ) |
| 553 | 599 | ||
| @@ -556,14 +602,15 @@ this function can be used as :notify for the widget." | |||
| 556 | (mouse-set-point event) | 602 | (mouse-set-point event) |
| 557 | (forward-line 1) | 603 | (forward-line 1) |
| 558 | (beginning-of-line) | 604 | (beginning-of-line) |
| 559 | (widget-put widget 'prj-other-widget | 605 | (setq w (widget-create 'editable-list |
| 560 | (widget-create 'editable-list | 606 | :entry-format "%i%d %v" |
| 561 | :entry-format "%i%d %v" | 607 | :notify 'ada-prj-field-modified |
| 562 | :notify 'ada-prj-field-modified | 608 | :help-echo (widget-get widget 'prj-help) |
| 563 | :help-echo (widget-get widget 'prj-help) | 609 | :value value |
| 564 | :value value | 610 | (list 'editable-field :keymap widget-keymap))) |
| 565 | (list 'editable-field | 611 | (widget-put widget 'prj-other-widget w) |
| 566 | :keymap widget-keymap))) | 612 | (widget-put w ':prj-field field) |
| 613 | (widget-put widget ':prj-field field) | ||
| 567 | (widget-default-value-set widget "Hide Value") | 614 | (widget-default-value-set widget "Hide Value") |
| 568 | ) | 615 | ) |
| 569 | ) | 616 | ) |
| @@ -609,6 +656,7 @@ AFTER-TEXT is inserted just after the widget." | |||
| 609 | (list 'quote field))) | 656 | (list 'quote field))) |
| 610 | "Load Recursive Directory") | 657 | "Load Recursive Directory") |
| 611 | (widget-insert "\n ${build_dir}\n"))) | 658 | (widget-insert "\n ${build_dir}\n"))) |
| 659 | |||
| 612 | (set 'widget | 660 | (set 'widget |
| 613 | (if is-list | 661 | (if is-list |
| 614 | (if (< (length value) 15) | 662 | (if (< (length value) 15) |
| @@ -618,11 +666,11 @@ AFTER-TEXT is inserted just after the widget." | |||
| 618 | :help-echo help-text | 666 | :help-echo help-text |
| 619 | :value value | 667 | :value value |
| 620 | (list 'editable-field :keymap widget-keymap)) | 668 | (list 'editable-field :keymap widget-keymap)) |
| 669 | |||
| 621 | (let ((w (widget-create 'push-button | 670 | (let ((w (widget-create 'push-button |
| 622 | :notify 'ada-prj-show-value | 671 | :notify 'ada-prj-show-value |
| 623 | "Show value"))) | 672 | "Show value"))) |
| 624 | (widget-insert "\n") | 673 | (widget-insert "\n") |
| 625 | (widget-put w 'prj-field field) | ||
| 626 | (widget-put w 'prj-help help-text) | 674 | (widget-put w 'prj-help help-text) |
| 627 | (widget-put w 'prj-other-widget nil) | 675 | (widget-put w 'prj-other-widget nil) |
| 628 | w) | 676 | w) |
| @@ -633,7 +681,7 @@ AFTER-TEXT is inserted just after the widget." | |||
| 633 | :help-echo help-text | 681 | :help-echo help-text |
| 634 | :keymap widget-keymap | 682 | :keymap widget-keymap |
| 635 | value))) | 683 | value))) |
| 636 | (widget-put widget 'prj-field field) | 684 | (widget-put widget ':prj-field field) |
| 637 | (if after-text | 685 | (if after-text |
| 638 | (widget-insert after-text)) | 686 | (widget-insert after-text)) |
| 639 | (widget-insert "\n") | 687 | (widget-insert "\n") |
| @@ -643,7 +691,6 @@ AFTER-TEXT is inserted just after the widget." | |||
| 643 | ;; Set the keymap once and for all, so that the keys set by the user in his | 691 | ;; Set the keymap once and for all, so that the keys set by the user in his |
| 644 | ;; config file are not overwritten every time we open a new file. | 692 | ;; config file are not overwritten every time we open a new file. |
| 645 | (ada-prj-add-keymap) | 693 | (ada-prj-add-keymap) |
| 646 | (ada-prj-add-ada-menu) | ||
| 647 | 694 | ||
| 648 | (provide 'ada-prj) | 695 | (provide 'ada-prj) |
| 649 | 696 | ||