Changeset 18858
- Timestamp:
- 09/05/08 00:01:18 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/anything-c-moccur/branches/new-anything/anything-c-moccur.el
r18828 r18858 218 218 219 219 (defun anything-c-moccur-initialize () 220 (setq anything-c-moccur-anything-invoking-flag t) 221 (setq anything-c-moccur-anything-current-buffer (current-buffer)) 222 (setq anything-c-moccur-saved-info nil)) 220 (setq anything-c-moccur-saved-info nil 221 anything-c-moccur-anything-invoking-flag t)) 223 222 224 223 (defun anything-c-moccur-anything-try-execute-persistent-action () 225 (when anything-c-moccur-enable-auto-look-flag 226 (anything-execute-persistent-action))) 224 (when (and anything-c-moccur-enable-auto-look-flag 225 anything-c-moccur-anything-invoking-flag) 226 (unless (zerop (buffer-size (get-buffer (anything-buffer-get)))) 227 (anything-execute-persistent-action)))) 227 228 228 229 (defmacro anything-c-moccur-with-anything-env (sources &rest body) … … 234 235 anything-c-moccur-anything-idle-delay) 235 236 (t anything-idle-delay)))) 236 (anything-c-moccur-initialize)237 237 (add-hook 'anything-c-moccur-anything-after-update-hook 'anything-c-moccur-anything-try-execute-persistent-action) 238 238 (unwind-protect … … 241 241 (remove-hook 'anything-c-moccur-anything-after-update-hook 'anything-c-moccur-anything-try-execute-persistent-action)))) 242 242 243 (defun anything-c-moccur-anything-update-initial-pattern ()244 (let ((minibuffer-window (active-minibuffer-window)))245 (when (and minibuffer-window246 (stringp anything-c-moccur-anything-initial-pattern))247 (with-current-buffer (window-buffer minibuffer-window)248 (insert anything-c-moccur-anything-initial-pattern)249 (anything-check-minibuffer-input)))))250 251 (defadvice anything (around anything-c-moccur-enable-initial-pattern activate)252 (cond ((and (boundp 'anything-c-moccur-anything-invoking-flag)253 anything-c-moccur-anything-invoking-flag254 (not (string-equal "" anything-c-moccur-anything-initial-pattern)))255 (add-hook 'minibuffer-setup-hook 'anything-c-moccur-anything-update-initial-pattern)256 (unwind-protect257 ad-do-it258 (remove-hook 'minibuffer-setup-hook 'anything-c-moccur-anything-update-initial-pattern)))259 (t260 ad-do-it)))261 262 243 (defun anything-c-moccur-clean-up () 263 244 (setq anything-c-moccur-anything-invoking-flag nil) 264 265 245 (when (overlayp anything-c-moccur-current-line-overlay) 266 246 (delete-overlay anything-c-moccur-current-line-overlay))) 267 268 (defadvice anything-cleanup (after anything-c-moccur-clean-up activate protect)269 (ignore-errors270 (anything-c-moccur-clean-up)))271 247 272 248 ;; (anything-next-line) 後のanything-update-hook … … 274 250 (defvar anything-c-moccur-anything-after-update-hook nil) 275 251 (defadvice anything-process-delayed-sources (after anything-c-moccur-anything-after-update-hook activate protect) 276 (when (and (boundp 'anything-c-moccur-anything-invoking-flag)277 anything-c-moccur-anything-invoking-flag)278 (ignore-errors279 (run-hooks 'anything-c-moccur-anything-after-update-hook))))252 (when (and (boundp 'anything-c-moccur-anything-invoking-flag) 253 anything-c-moccur-anything-invoking-flag) 254 (ignore-errors 255 (run-hooks 'anything-c-moccur-anything-after-update-hook)))) 280 256 281 257 (defadvice anything-select-action (before anything-c-moccur-saved-info activate) … … 364 340 365 341 (defun anything-c-moccur-occur-by-moccur-get-candidates () 366 (anything-c-moccur-moccur-search anything-pattern t (list anything-c -moccur-anything-current-buffer))342 (anything-c-moccur-moccur-search anything-pattern t (list anything-current-buffer)) 367 343 (anything-c-moccur-occur-by-moccur-scraper)) 368 344 369 345 (defun anything-c-moccur-occur-by-moccur-persistent-action (candidate) 370 (pop-to-buffer anything-c-moccur-anything-current-buffer)371 346 (anything-c-moccur-widen-if-need) 372 347 (goto-line (string-to-number candidate)) … … 389 364 (action . (("Goto line" . anything-c-moccur-occur-by-moccur-goto-line))) 390 365 (persistent-action . anything-c-moccur-occur-by-moccur-persistent-action) 366 (init . anything-c-moccur-initialize) 367 (cleanup . anything-c-moccur-clean-up) 391 368 (match . (identity)) 392 369 (requires-pattern . 3) … … 399 376 (let* ((initial-pattern (if anything-c-moccur-enable-initial-pattern 400 377 (or (thing-at-point 'symbol) "") 401 "")) 402 (anything-c-moccur-anything-initial-pattern initial-pattern)) 378 ""))) 403 379 (when anything-c-moccur-push-mark-flag 404 380 (push-mark)) 405 (anything ))))381 (anything nil initial-pattern)))) 406 382 407 383 (defun anything-c-moccur-occur-by-moccur-only-function () 408 384 (interactive) 409 385 (anything-c-moccur-with-anything-env (list anything-c-source-occur-by-moccur) 410 (let ((anything-c-moccur-anything-initial-pattern "! ")) 411 (when anything-c-moccur-push-mark-flag 412 (push-mark)) 413 (anything)))) 386 (when anything-c-moccur-push-mark-flag 387 (push-mark)) 388 (anything nil "! "))) 414 389 415 390 (defun anything-c-moccur-occur-by-moccur-only-comment () 416 391 (interactive) 417 392 (anything-c-moccur-with-anything-env (list anything-c-source-occur-by-moccur) 418 (let ((anything-c-moccur-anything-initial-pattern ";;; ")) 419 (when anything-c-moccur-push-mark-flag 420 (push-mark)) 421 (anything)))) 393 (when anything-c-moccur-push-mark-flag 394 (push-mark)) 395 (anything ";;; "))) 422 396 423 397 ;;; dmoccur … … 500 474 (match . (identity)) 501 475 (requires-pattern . 5) 476 (init . anything-c-moccur-initialize) 477 (cleanup . anything-c-moccur-clean-up) 502 478 (delayed) 503 479 (volatile))) … … 536 512 (match . (identity)) 537 513 (requires-pattern . 3) 514 (init . anything-c-moccur-initialize) 515 (cleanup . anything-c-moccur-clean-up) 538 516 (delayed) 539 517 (volatile))) … … 622 600 (anything-c-moccur-match-only-internal "\" ")) 623 601 602 603 (dont-compile 604 (when (fboundp 'expectations) 605 (expectations 606 (desc "initialize test") 607 (expect t 608 (let (v) 609 (anything-test-candidates 610 '(((name . "TEST") 611 (candidates "foo") 612 (init . (lambda () 613 (anything-c-moccur-initialize) 614 (setq v anything-c-moccur-anything-invoking-flag))) 615 (cleanup . anything-c-moccur-clean-up)))) 616 v)) 617 (desc "cleanup test") 618 (expect nil 619 (let ((anything-c-moccur-anything-invoking-flag t)) 620 (anything-test-candidates 621 '(anything-c-source-occur-by-moccur)) 622 anything-c-moccur-anything-invoking-flag)) 623 (desc "anything-c-source-occur-by-moccur") 624 (expect '(("Occur by Moccur" (" 2 bbb"))) 625 (let ((buf (get-buffer-create "*test anything-c-moccur*"))) 626 (with-current-buffer buf 627 (insert "aaa\nbbb\nccc") 628 (prin1 629 (anything-test-candidates 630 '(anything-c-source-occur-by-moccur) "bbb") 631 (kill-buffer buf))))) 632 ))) 633 634 624 635 (provide 'anything-c-moccur) 625 636
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)