diff options
Diffstat (limited to 'scripts/kde-emacs/kde-emacs-utils.el')
-rw-r--r-- | scripts/kde-emacs/kde-emacs-utils.el | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/scripts/kde-emacs/kde-emacs-utils.el b/scripts/kde-emacs/kde-emacs-utils.el index c6904539..37cc8977 100644 --- a/scripts/kde-emacs/kde-emacs-utils.el +++ b/scripts/kde-emacs/kde-emacs-utils.el @@ -41,9 +41,9 @@ This function does not do any hidden buffer changes." (let (found) (save-excursion (beginning-of-buffer) - (setq found (re-search-forward "^using" nil 1)) + (set found (re-search-forward "^using" nil 1)) (if found - (setq found (search-forward namespace (line-end-position) 1)) + (set found (search-forward namespace (line-end-position) 1)) ) ) found) @@ -55,9 +55,9 @@ This function does not do any hidden buffer changes." (let (found) (save-excursion (beginning-of-buffer) - (setq found (re-search-forward "^namespace" nil 1)) + (set found (re-search-forward "^namespace" nil 1)) (if found - (setq found (search-forward namespace (line-end-position) 1)) + (set found (search-forward namespace (line-end-position) 1)) ) ) found) @@ -88,7 +88,7 @@ This function does not do any hidden buffer changes." (re-search-forward "[ \t]" nil t)) (while (looking-at "[ \t]") (forward-char 1)) - (setq start (point)) + (set start (point)) ; Parse class name ("Foo" or "Foo::Bar::Blah"). ; Beware of "Foo:" (while (or (looking-at "[A-Za-z0-9_]") (looking-at "::")) @@ -99,9 +99,9 @@ This function does not do any hidden buffer changes." ) (cond (class ; class found already, so the rest goes into the namespace - (setq namespace (concat (buffer-substring start (point)) "::" namespace))) + (set namespace (concat (buffer-substring start (point)) "::" namespace))) (t ; class==nil - (setq class (buffer-substring start (point))))) + (set class (buffer-substring start (point))))) ) ; Go up one level again (let ((pos (c-safe-scan-lists (point) -1 1))) @@ -123,7 +123,7 @@ This function does not do any hidden buffer changes." (re-search-backward "^[ \t]*") (while (looking-at "[ \t]") (forward-char 1)) - (setq function (buffer-substring (point) end)) + (set function (buffer-substring (point) end)) ) ) ; end of global save-excursion (cons namespace (cons class function)) ; the returned value @@ -133,24 +133,24 @@ This function does not do any hidden buffer changes." ; get rid of virtual, static, multiple spaces, default values. (defun canonical-function-sig (function) (and (string-match "[ \t]*\\<virtual\\>[ \t]*" function) - (setq function (replace-match " " t t function))) + (set function (replace-match " " t t function))) (and (string-match "^\\(virtual\\>\\)?[ \t]*" function) - (setq function (replace-match "" t t function))) + (set function (replace-match "" t t function))) (and (string-match "^\\(explicit\\>\\)?[ \t]*" function) - (setq function (replace-match "" t t function))) + (set function (replace-match "" t t function))) (and (string-match "^\\(static\\>\\)?[ \t]*" function) - (setq function (replace-match "" t t function))) + (set function (replace-match "" t t function))) (while (string-match " +" function) ; simplifyWhiteSpace - (setq function (replace-match " " t t function))) + (set function (replace-match " " t t function))) (while (string-match "\t+" function) - (setq function (replace-match " " t t function))) + (set function (replace-match " " t t function))) (while (string-match "^ " function) ; remove leading whitespace - (setq function (replace-match "" t t function))) + (set function (replace-match "" t t function))) (let ((startargs (string-match "(" function))) (while (string-match " ?=[^,)]+" function startargs) ; remove default values - (setq function (replace-match " " t t function)))) + (set function (replace-match " " t t function)))) (while (string-match " +," function) ; remove space before commas - (setq function (replace-match "," t t function))) + (set function (replace-match "," t t function))) function ; the return value ) @@ -164,13 +164,13 @@ This function does not do any hidden buffer changes." (and (stringp class) (cond ((string-match (concat "^ *" class "[ \\t]*(") function) ; constructor - (setq insertion-string + (set insertion-string (replace-match (concat namespace class "::" class "(") t t function) )) ((string-match (concat "^ *~" class "[ \\t]*(") function) ; destructor - (setq insertion-string + (set insertion-string (replace-match (concat namespace class "::~" class "(") t t function) @@ -179,7 +179,7 @@ This function does not do any hidden buffer changes." (if (not (stringp insertion-string)) ; no ctor nor dtor (if (or (string-match " *\\([a-zA-Z0-9_]+\\)[ \\t]*(" function) ; normal method (string-match " *\\(operator[^ \\t]+\\)[ \\t]*(" function)) ; operator - (setq insertion-string + (set insertion-string (replace-match (if class (concat " " namespace class "::" "\\1(") ; c++ method @@ -216,8 +216,8 @@ This function does not do any hidden buffer changes." (let ((a (fume-function-before-point))) (and (string-match "^\\(.*\\)::\\(.*\\)$" a) (progn - (setq class (match-string 1 a)) - (setq function (match-string 2 a)) + (set class (match-string 1 a)) + (set function (match-string 2 a)) (kde-switch-cpp-h) (goto-char 0) ; Look for beginning of class ("\\s-+" means whitespace including newlines) @@ -234,27 +234,27 @@ This function does not do any hidden buffer changes." (let ((mup (method-under-point)) (sig "") (pos 0)) - (setq namespace (car mup)) - (setq class (car (cdr mup))) - (setq function (cdr (cdr mup))) + (set namespace (car mup)) + (set class (car (cdr mup))) + (set function (cdr (cdr mup))) (kde-switch-cpp-h) ;; First search with namespace prefixed (goto-char 0) - (setq sig (kde-remove-newline (kde-function-impl-sig namespace class function))) + (set sig (kde-remove-newline (kde-function-impl-sig namespace class function))) (if (string-match "(.*" sig) ; remove args - (setq sig (replace-match "" nil t sig))) - (setq found (re-search-forward (concat "^[^()]*" (kde-function-regexp-quote sig) "[ \t]*(") nil t) ) + (set sig (replace-match "" nil t sig))) + (set found (re-search-forward (concat "^[^()]*" (kde-function-regexp-quote sig) "[ \t]*(") nil t) ) (if (not found) (progn ; Now search without name space prefix (goto-char 0) - (setq sig (kde-remove-newline (kde-function-impl-sig "" class function))) + (set sig (kde-remove-newline (kde-function-impl-sig "" class function))) (if (string-match "(.*" sig) ; remove args - (setq sig (replace-match "" nil t sig))) + (set sig (replace-match "" nil t sig))) (re-search-forward (concat "^[^()]*" (kde-function-regexp-quote sig) "[ \t]*(") nil t) ) ) ))))) @@ -280,7 +280,7 @@ This function does not do any hidden buffer changes." (start nil) (newcppfile nil) ) - (setq insertion-string + (set insertion-string (concat insertion-string "\n{\n" (replace-in-string kde-make-member-default-impl "FUNCTION" ; the function name and args, without newlines @@ -299,19 +299,19 @@ This function does not do any hidden buffer changes." (forward-char -1)) (forward-char 1) ; move to next method again if we're at a pure virtual method - (setq moveToNext (looking-at "[ \t]*=[ \t]*0;")) + (set moveToNext (looking-at "[ \t]*=[ \t]*0;")) ) ) ) - (setq newcppfile (not (cdr (kde-file-get-cpp-h)))) + (set newcppfile (not (cdr (kde-file-get-cpp-h)))) (if (string-match "\\.h$" file) (kde-switch-cpp-h) ) (goto-char (point-max)) (kde-comments-begin) (kde-skip-blank-lines) - (setq msubstr (buffer-substring (point-at-bol) (point-at-eol))) + (set msubstr (buffer-substring (point-at-bol) (point-at-eol))) (if (string-match "^#include.*moc.*" msubstr) (progn (forward-line -1) @@ -330,7 +330,7 @@ This function does not do any hidden buffer changes." (c-indent-defun) (save-excursion (and (string-match ".*/" file) - (setq file (replace-match "" t nil file))) + (set file (replace-match "" t nil file))) (and (string-match "\\.h$" file) (functionp 'kdab-insert-include-file) (kdab-insert-include-file file 't nil))) @@ -403,14 +403,14 @@ This function does not do any hidden buffer changes." (iters (min (length parts) kde-header-protection-parts-to-show))) (dotimes (i iters) (let ((part (pop parts))) - (setq definablestring + (set definablestring (concat (upcase (replace-in-string part "[\\.-]" "_")) (if (not first-iter) "_" "") definablestring ) ) - (setq first-iter nil) + (set first-iter nil) ) ) definablestring @@ -435,13 +435,13 @@ This function does not do any hidden buffer changes." (if (not (c-in-literal)) (let ((n nil) (except nil)) (save-excursion - (setq n (or (progn (forward-char -2) (looking-at "if")) + (set n (or (progn (forward-char -2) (looking-at "if")) (progn (forward-char -1) (looking-at "for")) (progn (forward-char -1) (looking-at "case")) (progn (forward-char -1) (looking-at "while")) ) ) - (setq except (or (progn (forward-char -2) (looking-at "kdDebug")) + (set except (or (progn (forward-char -2) (looking-at "kdDebug")) (looking-at "kdError") (progn (forward-char -2) (looking-at "kdWarning")) ) @@ -464,9 +464,9 @@ This function does not do any hidden buffer changes." (if (not (c-in-literal)) (let ((remv nil) (nospac nil)) (forward-char -2) - (setq remv (looking-at "( ")) ; () -> we'll have to remove that space + (set remv (looking-at "( ")) ; () -> we'll have to remove that space (forward-char 1) - (setq nospac ; no space to be added + (set nospac ; no space to be added (or (looking-at " ") (looking-at "(") (save-excursion ; check for kdDebug(123 @@ -520,15 +520,15 @@ This function does not do any hidden buffer changes." (save-excursion (save-excursion (if (re-search-forward "[a-zA-Z]" (point-at-eol) t) - (setq oneliner t))) + (set oneliner t))) (forward-char -1) ; These three lines are for the situation where (if (not (looking-at " ")) ; the user already have inserted a space after (forward-char 1) ; the closing parenthesis - (setq spacep t)) + (set spacep t)) (forward-char -2) - (setq o (looking-at "()")) + (set o (looking-at "()")) (forward-char 1) - (setq n (looking-at ")")) + (set n (looking-at ")")) (if (and (not oneliner) (not (eq @@ -538,7 +538,7 @@ This function does not do any hidden buffer changes." (next-line 1) (beginning-of-line) (if (re-search-forward "[a-zA-Z]" (point-at-eol) t) - (setq c (eq (car (car (c-guess-basic-syntax))) 'substatement))) + (set c (eq (car (car (c-guess-basic-syntax))) 'substatement))) ) ) ) @@ -617,10 +617,10 @@ This function does not do any hidden buffer changes." (objext nil)) (if (file-readable-p "Makefile.am") - (setq objext "\.lo") - (setq objext "\.o")) - (if (string-match "\.cpp$" f) (setq f (replace-match objext t t f))) - (if (string-match "\.cc$" f) (setq f (replace-match objext t t f))) + (set objext "\.lo") + (set objext "\.o")) + (if (string-match "\.cpp$" f) (set f (replace-match objext t t f))) + (if (string-match "\.cc$" f) (set f (replace-match objext t t f))) (compile (concat kde-emacs-make " " f))) ) @@ -672,17 +672,17 @@ This function does not do any hidden buffer changes." (ret) ) (while (< pos l) - (setq oldpos (+ pos 1)) - (setq pos (string-match "[,]" string (+ pos 1))) - (unless pos (setq pos l)) - (setq currange (substring string oldpos pos)) + (set oldpos (+ pos 1)) + (set pos (string-match "[,]" string (+ pos 1))) + (unless pos (set pos l)) + (set currange (substring string oldpos pos)) (string-match "[0-9]+" currange) - (setq startyear (string-to-int (match-string 0 currange))) - (setq endyear + (set startyear (string-to-int (match-string 0 currange))) + (set endyear (if (string-match "-" currange) (string-to-int (substring currange (match-end 0))) startyear)) - (setq ret (cons (cons startyear endyear) ret)) + (set ret (cons (cons startyear endyear) ret)) ) ret ) @@ -694,14 +694,14 @@ This function does not do any hidden buffer changes." (let ((ret)) (dolist (range ranges ret) (when (and (>= year (car range)) (<= year (cdr range))) - (setq ret t)) + (set ret t)) ))) (defun kde-year-range-to-string (ranges) "converts ranges to a string.." (let ((ret "")) (dolist (range ranges) - (setq ret + (set ret (concat (int-to-string (car range)) (if (/= (cdr range) (car range)) @@ -712,7 +712,7 @@ This function does not do any hidden buffer changes." ) ) ; remove extraneous ", " - (setq ret (substring ret 0 (- (length ret) 2))) + (set ret (substring ret 0 (- (length ret) 2))) ) ) @@ -725,7 +725,7 @@ This function does not do any hidden buffer changes." (setcar range (cons (car nyears) (cdr years))) (setcdr range (cddr range))) ) - (setq range (cdr range)) + (set range (cdr range)) ) origrange ) @@ -738,16 +738,16 @@ This function does not do any hidden buffer changes." (cond ((and (>= year (car years)) (<= year (cdr years)) ; year is already in the range.. - (setq range nil))) + (set range nil))) ((= year (+ (cdr years) 1)) (setcdr years year) - (setq range nil)) + (set range nil)) ((= year (- (car years) 1)) (setcar years year) - (setq range nil)) + (set range nil)) ) ) - (setq range (cdr range)) + (set range (cdr range)) ) (kde-year-range-cleanup range) ) @@ -768,15 +768,15 @@ This function does not do any hidden buffer changes." (this-year (string-to-int (format-time-string "%Y")))) (when (not (kde-year-range-contains-year years this-year)) (kde-year-range-add-year years this-year)) - (setq new-copyright-string + (set new-copyright-string (concat new-copyright-string (kde-year-range-to-string years))) ; finish new-copyright-string - (setq new-copyright-string + (set new-copyright-string (concat new-copyright-string " " kde-full-name " <" kde-email ">")) (beginning-of-line) (re-search-forward "Copyright ([Cc])") (beginning-of-line) - (setq wascomment + (set wascomment (buffer-substring (point) (match-beginning 0) )) @@ -790,7 +790,7 @@ This function does not do any hidden buffer changes." (progn (goto-char first-copyright-str) (beginning-of-line) - (setq wascomment (buffer-substring (point) (match-beginning 0))) + (set wascomment (buffer-substring (point) (match-beginning 0))) (forward-line 1) ) (goto-line 2)) @@ -820,12 +820,12 @@ This function does not do any hidden buffer changes." (final)) (save-excursion (beginning-of-buffer) - (setq startpoint (point)) - (setq endpoint (point-at-eol))) - (setq firstline (buffer-substring startpoint endpoint)) + (set startpoint (point)) + (set endpoint (point-at-eol))) + (set firstline (buffer-substring startpoint endpoint)) (if (string-match "-\*-\\([A-Za-z0-9\-\+\:\; ]+\\)-\*-" firstline) (delete-region startpoint endpoint)) - (setq final (concat "-*- " + (set final (concat "-*- " "Mode: " mode-name "; " "c-basic-offset: " (prin1-to-string c-basic-offset) "; " "indent-tabs-mode: " (prin1-to-string indent-tabs-mode) "; " @@ -848,11 +848,11 @@ This function does not do any hidden buffer changes." (if (looking-at "#include \"") (progn (forward-char 10) - (setq begin (point)) + (set begin (point)) (re-search-forward "\"" nil t) (backward-char 1) - (setq file (buffer-substring begin (point))) - (setq buffer (current-buffer)) + (set file (buffer-substring begin (point))) + (set buffer (current-buffer)) (qt-follow-includes file) (kill-buffer buffer) ) @@ -873,18 +873,18 @@ This function does not do any hidden buffer changes." ) (save-excursion ; The Qt3 case: the includes are directly in $QTDIR/include/, lowercased - (setq f (concat qtinc (downcase class) ".h" )) + (set f (concat qtinc (downcase class) ".h" )) (if (file-readable-p f) - (setq file f) + (set file f) ; For some Qt3/e classes: add _qws - (setq f (concat qtinc (downcase class) "_qws.h" )) + (set f (concat qtinc (downcase class) "_qws.h" )) (if (file-readable-p f) - (setq file f) + (set file f) ; The Qt4 case: the includes are in $QTDIR/include/QSomething/, in original case - (setq files (directory-files qtinc t nil "dirsonly")) + (set files (directory-files qtinc t nil "dirsonly")) (dolist (f files nil) (if (file-readable-p (concat f "/" class) ) - (setq file (concat f "/" class)))) + (set file (concat f "/" class)))) )) (and file (qt-follow-includes file)) |