 ;; Doesn't do anything useful...
 ;; (global-set-key (kbd "C-:") (lambda () (interactive)
 ;; (dwim-start-of-line 'comment-or-uncomment-region)))
-(global-set-key (kbd "C-M-;") (lambda () (interactive)
-                                (function-on-block 'comment-or-uncomment-region)))
+;; (global-set-key (kbd "C-M-;") (lambda () (interactive)
+                                ;; (function-on-block 'comment-or-uncomment-region)))
 
 
 ;; eval
 (global-set-key (kbd "C-#") (lambda () (interactive) (dwim-end-of-line 'eval-region)))
 (global-set-key (kbd "M-#") (lambda () (interactive) (dwim-entire-line 'eval-region)))
 (global-set-key (kbd "C-S-#") (lambda () (interactive) (dwim-start-of-line 'eval-region)))
-(global-set-key (kbd "C-M-#") (lambda () (interactive) (function-on-block 'eval-region)))
+;; (global-set-key (kbd "C-M-#") (lambda () (interactive) (function-on-block 'eval-region)))
 
 
 ;; Some standard things from e.g. chrome

;; C-? : on region or to start of line
;; M-? : on region or all of line
;; M-S-? : on block (blankline seperated, incl. trailing newlines)
;; C-M-? : on function (or equvalent)


(defun go-to-beginning-of-block (&optional repeat)
  (interactive)
  (backward-paragraph)
  (next-line 1)
  (beginning-of-line))

(defun point-at-beginning-of-block (&optional repeat)
  (save-excursion (go-to-beginning-of-block) (point)))

(defun go-to-end-of-block (&optional repeat)
  (interactive)
  ;; Go to start first to make sure we don't end up at the end of the
  ;; *next* block (if we were in whitespace between the two). Then go to
  ;; the end of the text in this paragraph (usually whitespace delimited).
  (backward-paragraph)
  (forward-paragraph)

  ;; Now go past all the trailing whitespace too. If we hit the end of the
  ;; buffer during this search then the end of the buffer is the end of the
  ;; block.
  (forward-line -1)
  (unless (ignore-errors (search-forward-regexp "\n\n+" nil repeat))
    (goto-char (point-max))))

(defun point-at-end-of-block (&optional repeat)
  (save-excursion (go-to-end-of-block) (point)))

(defun point-at-beginning-of-next-line ()
  (save-excursion (end-of-line) (forward-line)

(global-set-key (kbd "C-x") (lambda () (interactive) (dwim-end-of-line 'kill-region)))
(global-set-key (kbd "M-x") (lambda () (interactive) (dwim-entire-line 'kill-region)))
(global-set-key (kbd "C-S-x") (lambda () (interactive) (dwim-start-of-line 'kill-region)))
;; (global-set-key (kbd "C-M-x") (lambda () (interactive) (function-on-block 'kill-region)))

;; Copy
(global-set-key (kbd "C-c") (lambda () (interactive) (dwim-end-of-line 'kill-ring-save)))
(global-set-key (kbd "M-c") (lambda () (interactive) (dwim-entire-line 'kill-ring-save)))
(global-set-key (kbd "C-S-c") (lambda () (interactive) (dwim-start-of-line 'kill-ring-save)))
;; (global-set-key (kbd "C-M-c") (lambda () (interactive) (function-on-block 'kill-ring-save)))

;; Paste (and cycle through pastes)
(global-set-key (kbd "C-v") 'yank)
