123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- (require 'ede)
- (defun ede-update-version (newversion)
- "Update the current projects main version number.
- Argument NEWVERSION is the version number to use in the current project."
- (interactive (list (let* ((o (ede-toplevel))
- (v (oref o version)))
- (read-string (format "Update Version (was %s): " v)
- v nil v))))
- (let ((ede-object (ede-toplevel)))
-
- (unless (string= (oref ede-object :version) newversion)
- (oset ede-object :version newversion)
- (project-update-version ede-object)
- (ede-update-version-in-source ede-object newversion))))
- (defmethod project-update-version ((ot ede-project))
- "The :version of the project OT has been updated.
- Handle saving, or other detail."
- (error "project-update-version not supported by %s" (object-name ot)))
- (defmethod ede-update-version-in-source ((this ede-project) version)
- "Change occurrences of a version string in sources.
- In project THIS, cycle over all targets to give them a chance to set
- their sources to VERSION."
- (ede-map-targets this (lambda (targ)
- (ede-update-version-in-source targ version))))
- (defmethod ede-update-version-in-source ((this ede-target) version)
- "In sources for THIS, change version numbers to VERSION."
- (if (and (slot-boundp this 'versionsource)
- (oref this versionsource))
- (let ((vs (oref this versionsource)))
- (while vs
- (with-current-buffer (find-file-noselect
- (ede-expand-filename this (car vs)))
- (goto-char (point-min))
- (let ((case-fold-search t))
- (if (re-search-forward "version:\\s-*\\([^ \t\n]+\\)" nil t)
- (progn
- (save-match-data
- (ede-make-buffer-writable))
- (delete-region (match-beginning 1)
- (match-end 1))
- (goto-char (match-beginning 1))
- (insert version)))))
- (setq vs (cdr vs))))))
- (defun ede-make-buffer-writable (&optional buffer)
- "Make sure that BUFFER is writable.
- If BUFFER isn't specified, use the current buffer."
- (save-excursion
- (if buffer (set-buffer buffer))
- (toggle-read-only -1)))
- (provide 'ede/util)
|