On 07/06/2011 12:01 AM, Kiwon Um wrote:
> Kiwon Um<um.kiwon@...> writes:
>
>> Dear cedet-devel team,
>>
>> please check the modern forms of macros used for configure.ac:
>> http://sources.redhat.com/automake/automake.html#Public-Macros
>>
>> The latest EDE package seems ruin the configure.ac file when use only
>> AM_INIT_AUTOMAKE macro without any option.
>>
>> Thanks.
>>
>> --
>> Kiwon Um
>
> This can be fixed as follows:
>
> autoconf-edit.el:
>
> (defun autoconf-set-version (version)
> "Set the version used with automake to VERSION."
> (if (not (stringp version))
> (signal 'wrong-type-argument '(stringp version)))
> (if (not (autoconf-find-last-macro "AC_INIT"))
> (error "Cannot update version")
> ;; Move to correct position.
> (autoconf-edit-cycle
> (autoconf-delete-parameter 2)
> (autoconf-insert (concat "[" version "]")))))
>
> Btw, I have no idea of the compatibility with the previous autotool.
Hi,
Can you try out the following patch? This should work with both old and
new flavors of configure.ac files.
I had to add a parameter counter, then use that to figure out if there
was a version associated with any of the macros.
It may also be time to update the ede-autoconf.srt template also.
Thanks
Eric
=== modified file 'ede/autoconf-edit.el'
*** ede/autoconf-edit.el 2010-07-24 13:55:40 +0000
--- ede/autoconf-edit.el 2011-08-03 01:17:25 +0000
***************
*** 1,6 ****
;;; autoconf-edit.el --- Keymap for autoconf
! ;; Copyright (C) 1998, 1999, 2000, 2009, 2010 Eric M. Ludlam
;; Author: Eric M. Ludlam <zappo@...>
;; Keywords: project
--- 1,6 ----
;;; autoconf-edit.el --- Keymap for autoconf
! ;; Copyright (C) 1998, 1999, 2000, 2009, 2010, 2011 Eric M. Ludlam
;; Author: Eric M. Ludlam <zappo@...>
;; Keywords: project
***************
*** 382,387 ****
--- 382,419 ----
(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.
***************
*** 407,418 ****
"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.
(autoconf-edit-cycle
(autoconf-delete-parameter 2)
! (autoconf-insert version))))
(defun autoconf-set-output (outputlist)
"Set the files created in AC_OUTPUT to OUTPUTLIST.
--- 439,457 ----
"Set the version used with automake to VERSION."
(if (not (stringp version))
(signal 'wrong-type-argument '(stringp version)))
! (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 (concat "[" version "]"))))
(defun autoconf-set-output (outputlist)
"Set the files created in AC_OUTPUT to OUTPUTLIST.
|