diff options
Diffstat (limited to 'lisp/cedet/ede/autoconf-edit.el')
-rw-r--r-- | lisp/cedet/ede/autoconf-edit.el | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/lisp/cedet/ede/autoconf-edit.el b/lisp/cedet/ede/autoconf-edit.el index e3c9d2cb4f8..8144b135ac5 100644 --- a/lisp/cedet/ede/autoconf-edit.el +++ b/lisp/cedet/ede/autoconf-edit.el @@ -165,6 +165,9 @@ items such as CHECK_HEADERS." (setq param (substring param (match-end 0)))) (when (string-match "\\s-*\\]?\\s-*\\'" param) (setq param (substring param 0 (match-beginning 0)))) + ;; Look for occurances of backslash newline + (while (string-match "\\s-*\\\\\\s-*\n\\s-*" param) + (setq param (replace-match " " t t param))) param) (defun autoconf-parameters-for-macro (macro &optional ignore-bol ignore-case) @@ -373,6 +376,38 @@ Optional argument BODY is the code to execute which edits the autoconf file." (string= autoconf-deleted-text autoconf-inserted-text)) (set-buffer-modified-p nil)))) +(defun autoconf-parameter-count () + "Return the number of parameters to the function on the current line." + (save-excursion + (beginning-of-line) + (let* ((end-of-cmd + (save-excursion + (if (re-search-forward "(" (point-at-eol) t) + (progn + (forward-char -1) + (forward-sexp 1) + (point)) + ;; Else, just return EOL. + (point-at-eol)))) + (cnt 0)) + (save-restriction + (narrow-to-region (point-at-bol) end-of-cmd) + (condition-case nil + (progn + (down-list 1) + (while (re-search-forward ", ?" end-of-cmd t) + (setq cnt (1+ cnt))) + (cond ((> cnt 1) + ;; If the # is > 1, then there is one fewer , than args. + (1+ cnt)) + ((not (looking-at "\\s-*)")) + ;; If there are 0 args, then we have to see if there is one arg. + (1+ cnt)) + (t + ;; Else, just return the 0. + cnt))) + (error 0)))))) + (defun autoconf-delete-parameter (index) "Delete the INDEXth parameter from the macro starting on the current line. Leaves the cursor where a new parameter can be inserted. @@ -396,12 +431,19 @@ INDEX starts at 1." "Set the version used with automake to VERSION." (if (not (stringp version)) (signal 'wrong-type-argument '(stringp version))) - (if (not (autoconf-find-last-macro "AM_INIT_AUTOMAKE")) - (error "Cannot update version") - ;; Move to correct position. + (if (and (autoconf-find-last-macro "AM_INIT_AUTOMAKE") + (>= (autoconf-parameter-count) 2)) + ;; We can edit right here. + nil + ;; Else, look for AC init instead. + (if (not (and (autoconf-find-last-macro "AC_INIT") + (>= (autoconf-parameter-count) 2))) + (error "Cannot update version"))) + + ;; Perform the edit. (autoconf-edit-cycle (autoconf-delete-parameter 2) - (autoconf-insert version)))) + (autoconf-insert (concat "[" version "]")))) (defun autoconf-set-output (outputlist) "Set the files created in AC_OUTPUT to OUTPUTLIST. |