Skip to content

Commit

Permalink
fix: working of other windows and tests (signal because of ecukes bugs)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrieanKhisbe committed Oct 9, 2017
1 parent 98cdc40 commit b87382d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
16 changes: 9 additions & 7 deletions features/step-definitions/omni-scratch-steps.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@
(bound-and-true-p omni-scratch-mode)))

(When "^I call with universal arg \"\\(.+\\)\"$"
(lambda (func)
(let ((v (vconcat [?\C-u ?\M-x] (string-to-vector func))))
(execute-kbd-macro v))))
(lambda (func)
(setq current-prefix-arg '(4))
(call-interactively (intern func))))

(Then "^I should have \\([0-9]+\\) windows$"
(lambda (nwindow)
(let ((windows (get-buffer-window-list)))
(eq nwindow (length windows)))))
(let ((windows (window-list)))
(cl-assert (eq (string-to-int nwindow) (length windows))
t "Wrong number of windows %s vs %s"))))

(Then "^I should have \"\\([^\"]+\\)\" buffer as window$"
(lambda (buffername)
(member (mapcar (lambda (bn) (equal bn buffername))
(mapcar 'buffer-name (mapcar 'window-buffer (get-buffer-window-list)))) t)))
(cl-assert (member t (mapcar (lambda (bn) (equal bn buffername))
(mapcar 'buffer-name (mapcar 'window-buffer (window-list)))))
t "Windows not present %s")))
28 changes: 14 additions & 14 deletions omni-scratch.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
;; 搂maybe: create or also switch to?
;; 搂TODO: rename?, kill interactive?
(let ((buffer (get-buffer-create name)))
(switch-to-buffer buffer)
(setq omni-scratch-latest-scratch-buffer buffer)
(when (> (length text) 0)
(erase-buffer)
(insert text))
(funcall mode)
(omni-scratch-mode)
;; 搂later: apply eventual modification to local modes.
;; [and var: maybe identify the scratch buffer]: local var and register in alist or so
(with-current-buffer buffer
(setq omni-scratch-latest-scratch-buffer buffer)
(when (> (length text) 0)
(erase-buffer)
(insert text))
(funcall mode)
(omni-scratch-mode))
;; 搂later: apply eventual modification to local modes.
;; [and var: maybe identify the scratch buffer]: local var and register in alist or so
buffer))

(defun omni-scratch-goto-latest ()
Expand All @@ -71,9 +71,9 @@
;; 搂maybe: specific background

(defun omni-scratch--interactive-arguments ()
(if (mark) ; was active-region-p but not working wwith ecukes
(list (prefix-numeric-value t) (region-beginning) (region-end))
(list (prefix-numeric-value t))))
(if (mark) ; was active-region-p but not working wwith ecukes
(list current-prefix-arg (region-beginning) (region-end))
(list current-prefix-arg)))

(defun omni-scratch--buffer-switch (buffer-name mode universal-arg &optional point mark)
"Create a new scratch buffer and switch to. Unless if in scratch buffer already"
Expand All @@ -82,11 +82,11 @@
(setq omni-scratch-origin-buffer nil))
(let ((current-buffer (current-buffer))
(buffer (omni-scratch-create-scratch-buffer
buffer-name mode
buffer-name mode
(if point (buffer-substring point mark) ""))))
(setq omni-scratch-origin-buffer current-buffer)
(if (equal universal-arg '(4))
(switch-to-buffer-other-window buffer)
(switch-to-buffer-other-window buffer)
(switch-to-buffer buffer)))))

;;;###autoload
Expand Down

0 comments on commit b87382d

Please sign in to comment.