|
@@ -1,92 +1,14 @@
|
|
|
|
+;;; Code:
|
|
(defvar he-search-loc-backward (make-marker))
|
|
(defvar he-search-loc-backward (make-marker))
|
|
(defvar he-search-loc-forward (make-marker))
|
|
(defvar he-search-loc-forward (make-marker))
|
|
|
|
|
|
-
|
|
|
|
-;; Hippie expand: sometimes too hip
|
|
|
|
-(setq hippie-expand-try-functions-list
|
|
|
|
- '(try-expand-dabbrev-closest-first
|
|
|
|
- try-complete-file-name
|
|
|
|
- try-expand-dabbrev-all-buffers
|
|
|
|
- try-expand-dabbrev-from-kill
|
|
|
|
- try-expand-all-abbrevs
|
|
|
|
- try-complete-lisp-symbol-partially
|
|
|
|
- try-complete-lisp-symbol))
|
|
|
|
-
|
|
|
|
;; Functions
|
|
;; Functions
|
|
-(defun try-expand-dabbrev-closest-first (old)
|
|
|
|
- "Try to expand word \"dynamically\", searching the current buffer.
|
|
|
|
-The argument OLD has to be nil the first call of this function, and t
|
|
|
|
-for subsequent calls (for further possible expansions of the same
|
|
|
|
-string). It returns t if a new expansion is found, nil otherwise."
|
|
|
|
- (let (expansion)
|
|
|
|
- (unless old
|
|
|
|
- (he-init-string (he-dabbrev-beg) (point))
|
|
|
|
- (set-marker he-search-loc-backward he-string-beg)
|
|
|
|
- (set-marker he-search-loc-forward he-string-end))
|
|
|
|
-
|
|
|
|
- (if (not (equal he-search-string ""))
|
|
|
|
- (save-excursion
|
|
|
|
- (save-restriction
|
|
|
|
- (if hippie-expand-no-restriction
|
|
|
|
- (widen))
|
|
|
|
-
|
|
|
|
- (let (forward-point
|
|
|
|
- backward-point
|
|
|
|
- forward-distance
|
|
|
|
- backward-distance
|
|
|
|
- forward-expansion
|
|
|
|
- backward-expansion
|
|
|
|
- chosen)
|
|
|
|
-
|
|
|
|
- ;; search backward
|
|
|
|
- (goto-char he-search-loc-backward)
|
|
|
|
- (setq expansion (he-dabbrev-search he-search-string t))
|
|
|
|
-
|
|
|
|
- (when expansion
|
|
|
|
- (setq backward-expansion expansion)
|
|
|
|
- (setq backward-point (point))
|
|
|
|
- (setq backward-distance (- he-string-beg backward-point)))
|
|
|
|
-
|
|
|
|
- ;; search forward
|
|
|
|
- (goto-char he-search-loc-forward)
|
|
|
|
- (setq expansion (he-dabbrev-search he-search-string nil))
|
|
|
|
-
|
|
|
|
- (when expansion
|
|
|
|
- (setq forward-expansion expansion)
|
|
|
|
- (setq forward-point (point))
|
|
|
|
- (setq forward-distance (- forward-point he-string-beg)))
|
|
|
|
-
|
|
|
|
- ;; choose depending on distance
|
|
|
|
- (setq chosen (cond
|
|
|
|
- ((and forward-point backward-point)
|
|
|
|
- (if (< forward-distance backward-distance) :forward :backward))
|
|
|
|
-
|
|
|
|
- (forward-point :forward)
|
|
|
|
- (backward-point :backward)))
|
|
|
|
-
|
|
|
|
- (when (equal chosen :forward)
|
|
|
|
- (setq expansion forward-expansion)
|
|
|
|
- (set-marker he-search-loc-forward forward-point))
|
|
|
|
-
|
|
|
|
- (when (equal chosen :backward)
|
|
|
|
- (setq expansion backward-expansion)
|
|
|
|
- (set-marker he-search-loc-backward backward-point))
|
|
|
|
-
|
|
|
|
- ))))
|
|
|
|
-
|
|
|
|
- (if (not expansion)
|
|
|
|
- (progn
|
|
|
|
- (if old (he-reset-string))
|
|
|
|
- nil)
|
|
|
|
- (progn
|
|
|
|
- (he-substitute-string expansion t)
|
|
|
|
- t))))
|
|
|
|
-
|
|
|
|
-(defun try-expand-line-closest-first (old)
|
|
|
|
|
|
+(defun distopico:try-expand-line-closest-first (old)
|
|
"Try to complete the current line to an entire line in the buffer.
|
|
"Try to complete the current line to an entire line in the buffer.
|
|
The argument OLD has to be nil the first call of this function, and t
|
|
The argument OLD has to be nil the first call of this function, and t
|
|
for subsequent calls (for further possible completions of the same
|
|
for subsequent calls (for further possible completions of the same
|
|
-string). It returns t if a new completion is found, nil otherwise."
|
|
|
|
|
|
+string). It returns t if a new completion is found, nil otherwise.
|
|
|
|
+from: https://gist.github.com/magnars/4060654"
|
|
(let ((expansion ())
|
|
(let ((expansion ())
|
|
(strip-prompt (and (get-buffer-process (current-buffer))
|
|
(strip-prompt (and (get-buffer-process (current-buffer))
|
|
comint-use-prompt-regexp
|
|
comint-use-prompt-regexp
|
|
@@ -156,18 +78,19 @@ string). It returns t if a new completion is found, nil otherwise."
|
|
(he-substitute-string expansion t)
|
|
(he-substitute-string expansion t)
|
|
t))))
|
|
t))))
|
|
|
|
|
|
-(defun hippie-expand-lines ()
|
|
|
|
- "Create own function to expand lines (C-S-.)"
|
|
|
|
|
|
+(defun distopico:hippie-expand-lines ()
|
|
|
|
+ "Create own function to expand lines."
|
|
(interactive)
|
|
(interactive)
|
|
(let ((hippie-expand-try-functions-list '(try-expand-line-closest-first
|
|
(let ((hippie-expand-try-functions-list '(try-expand-line-closest-first
|
|
try-expand-line-all-buffers)))
|
|
try-expand-line-all-buffers)))
|
|
(end-of-line)
|
|
(end-of-line)
|
|
(hippie-expand nil)))
|
|
(hippie-expand nil)))
|
|
|
|
|
|
-(defun hippie-expand-no-case-fold ()
|
|
|
|
- "Don't case-fold when expanding with hippe"
|
|
|
|
|
|
+(defun distopico:hippie-expand-no-case-fold ()
|
|
|
|
+ "Don't case-fold when expanding with `hippe-mode'."
|
|
(interactive)
|
|
(interactive)
|
|
(let ((case-fold-search nil))
|
|
(let ((case-fold-search nil))
|
|
(hippie-expand nil)))
|
|
(hippie-expand nil)))
|
|
|
|
|
|
(provide 'conf-hippie)
|
|
(provide 'conf-hippie)
|
|
|
|
+;;; conf-hippie.el ends here
|