From: Ian Kelling Date: Wed, 28 Sep 2016 01:03:33 +0000 (-0700) Subject: various fixes X-Git-Url: https://iankelling.org/git/?p=dot-emacs;a=commitdiff_plain;h=23b4a1a660d78999f72019414fc669239b8eed55 various fixes --- diff --git a/dev.org b/dev.org index f7bcedd..0b29988 100644 --- a/dev.org +++ b/dev.org @@ -4,5 +4,118 @@ and since it's pretty big, it's a bit annoying. We need at least one of these, even a blank one to avoid error on startup. #+begin_src emacs-lisp +(ivy-mode 1) +(add-hook 'text-mode-hook (lambda () (auto-fill-mode t))) +#+end_src + + +* ido +#+begin_src emacs-lisp + +;; easier to read, and more than the default 12 +(setq ido-separator nil) +(setq ido-max-prospects 20) + +(ido-mode t) +(ido-everywhere t) ;; file dialogs + +;; do out of order matching when all else fails +(setq ido-enable-flex-matching t + ido-create-new-buffer 'always ;; create new buffer/file without asking + ido-use-filename-at-point 'guess ;; use filename at point if it makes sense + ido-save-directory-list-file "~/.emacs.d/.ido.last" + ido-default-file-method 'selected-window) ;; make duplicate windows +;; todo, the next 2 functions seem to do roughly the same. +;; figure out which one is better. the first comes from emacs starter kit, +;; i forget about the second. +(defun ido-imenu () + "Update the imenu index and then use ido to select a symbol to navigate to. + Symbols matching the text at point are put first in the completion list." + (interactive) + (imenu--make-index-alist) + (let ((name-and-pos '()) + (symbol-names '())) + (cl-flet ((addsymbols (symbol-list) + (when (listp symbol-list) + (dolist (symbol symbol-list) + (let ((name nil) (position nil)) + (cond + ((and (listp symbol) (imenu--subalist-p symbol)) + (addsymbols symbol)) + + ((listp symbol) + (setq name (car symbol)) + (setq position (cdr symbol))) + + ((stringp symbol) + (setq name symbol) + (setq position (get-text-property 1 'org-imenu-marker symbol)))) + + (unless (or (null position) (null name)) + (add-to-list 'symbol-names name) + (add-to-list 'name-and-pos (cons name position)))))))) + (addsymbols imenu--index-alist)) + ;; If there are matching symbols at point, put them at the beginning of `symbol-names'. + (let ((symbol-at-point (thing-at-point 'symbol))) + (when symbol-at-point + (let* ((regexp (concat (regexp-quote symbol-at-point) "$")) + (matching-symbols (delq nil (mapcar (lambda (symbol) + (if (string-match regexp symbol) symbol)) + symbol-names)))) + (when matching-symbols + (sort matching-symbols (lambda (a b) (> (length a) (length b)))) + (mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names)))) + matching-symbols))))) + (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names)) + (position (cdr (assoc selected-symbol name-and-pos)))) + (goto-char position)))) + +(defun ido-goto-symbol (&optional symbol-list) + "Refresh imenu and jump to a place in the buffer using Ido." + (interactive) + (unless (featurep 'imenu) + (require 'imenu nil t)) + (cond + ((not symbol-list) + (let ((ido-mode ido-mode) + (ido-enable-flex-matching + (if (boundp 'ido-enable-flex-matching) + ido-enable-flex-matching t)) + name-and-pos symbol-names position) + (unless ido-mode + (ido-mode 1) + (setq ido-enable-flex-matching t)) + (while (progn + (imenu--cleanup) + (setq imenu--index-alist nil) + (ido-goto-symbol (imenu--make-index-alist)) + (setq selected-symbol + (ido-completing-read "Symbol? " symbol-names)) + (string= (car imenu--rescan-item) selected-symbol))) + (unless (and (boundp 'mark-active) mark-active) + (push-mark nil t nil)) + (setq position (cdr (assoc selected-symbol name-and-pos))) + (cond + ((overlayp position) + (goto-char (overlay-start position))) + (t + (goto-char position))))) + ((listp symbol-list) + (dolist (symbol symbol-list) + (let (name position) + (cond + ((and (listp symbol) (imenu--subalist-p symbol)) + (ido-goto-symbol symbol)) + ((listp symbol) + (setq name (car symbol)) + (setq position (cdr symbol))) + ((stringp symbol) + (setq name symbol) + (setq position + (get-text-property 1 'org-imenu-marker symbol)))) + (unless (or (null position) (null name) + (string= (car imenu--rescan-item) name)) + (add-to-list 'symbol-names (substring-no-properties name)) + (add-to-list 'name-and-pos (cons (substring-no-properties name) position)))))))) #+end_src diff --git a/my-init.org b/my-init.org index d9bf515..1bd6421 100644 --- a/my-init.org +++ b/my-init.org @@ -47,9 +47,9 @@ alternate keyboards m-enter (kbd "M-m") c-enter (kbd "C-8"))) +(setq tp (string= (system-name) "tp")) (setq x200 (string= (system-name) "x2")) -(setq search-key (if x200 "" "")) -(setq shell-key (if x200 "" "")) +(setq laptop-keyboard (or tp x200)) #+end_src - Ubiquitous Packages which should be loaded on startup rather than @@ -160,6 +160,11 @@ If it is different, emacs will give a message about recovering it when you open +* TODO update comint-exec-1 +* TODO learn some more ivy mode stuff +* TODO disable return overriding ctrl-m +* TODO declarative package installations, +with documentation. * TODO shell mode reverse search hides 2nd+ line of multi-line result * TODO report bug in latest emacs, c-c ', does't exit org-mode src editing mode. @@ -377,7 +382,8 @@ if all else fails, edit the abbrev file #+begin_src emacs-lisp ;; auto-completion in minibuffer -(icomplete-mode) +;; disabled while I look for another alternative +;;(icomplete-mode) (require 'auto-complete-config) (ac-config-default) @@ -445,6 +451,8 @@ if all else fails, edit the abbrev file (setenv "EMACS" "") (setq explicit-bash-args nil) (setq comint-process-echoes t) +;; default of 30 is way too slow. todo, consider pushing this upstream +(setq rlc-attempts 5) (add-to-list 'ac-modes 'shell-mode) @@ -817,6 +825,18 @@ Things I tried which didn't work, which intuitively I think should work better: :PROPERTIES: :tangle: no :END: +** indent settings for git's perl code +don't have a way to set this automatically or a good place to put this +#+begin_src emacs-lisp +(setq + perl-indent-level 8 + perl-continued-statement-offset 8 + perl-continued-brace-offset -8 + perl-brace-offset 0 + perl-brace-imaginary-offset 0 + indent-tabs-mode t + ) +#+end_src ** org mode website #+begin_src emacs-lisp @@ -1126,6 +1146,8 @@ this looks nice, but it lags gnus just a bit ** readline complete fix, replaced with proper solution +update: I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS. + i had commented out a few lines here, but instead I am setting in my profile the environment variable I commented out here. Yes, that is not the best explanation, but I will probably delete this as old history anyways. @@ -1150,7 +1172,7 @@ old history anyways. ;; ian: commented this out ;;(unless (getenv "EMACS") ;; (list "EMACS=t")) - (list (format "INSIDE_EMACS=%s,comint" emacs-version)) + (list (format "RLC_INSIDE_EMACS=%s,comint" emacs-version)) process-environment)) (default-directory (if (file-accessible-directory-p default-directory) @@ -1682,117 +1704,6 @@ make all #+RESULTS: | (lambda nil (define-key haskell-interactive-mode-map (kbd ) (quote haskell-interactive-mode-newline-indent))) | (lambda nil (define-key haskell-interactive-mode-map \n nil) (define-key haskell-interactive-mode-map (kbd ) (quote haskell-interactive-mode-return))) | ac-haskell-process-setup | -* ido -#+begin_src emacs-lisp - -;; easier to read, and more than the default 12 -(setq ido-separator nil) -(setq ido-max-prospects 20) - -(ido-mode t) -(ido-everywhere t) ;; file dialogs - -;; do out of order matching when all else fails -(setq ido-enable-flex-matching t - ido-create-new-buffer 'always ;; create new buffer/file without asking - ido-use-filename-at-point 'guess ;; use filename at point if it makes sense - ido-save-directory-list-file "~/.emacs.d/.ido.last" - ido-default-file-method 'selected-window) ;; make duplicate windows -;; todo, the next 2 functions seem to do roughly the same. -;; figure out which one is better. the first comes from emacs starter kit, -;; i forget about the second. -(defun ido-imenu () - "Update the imenu index and then use ido to select a symbol to navigate to. - Symbols matching the text at point are put first in the completion list." - (interactive) - (imenu--make-index-alist) - (let ((name-and-pos '()) - (symbol-names '())) - (cl-flet ((addsymbols (symbol-list) - (when (listp symbol-list) - (dolist (symbol symbol-list) - (let ((name nil) (position nil)) - (cond - ((and (listp symbol) (imenu--subalist-p symbol)) - (addsymbols symbol)) - - ((listp symbol) - (setq name (car symbol)) - (setq position (cdr symbol))) - - ((stringp symbol) - (setq name symbol) - (setq position (get-text-property 1 'org-imenu-marker symbol)))) - - (unless (or (null position) (null name)) - (add-to-list 'symbol-names name) - (add-to-list 'name-and-pos (cons name position)))))))) - (addsymbols imenu--index-alist)) - ;; If there are matching symbols at point, put them at the beginning of `symbol-names'. - (let ((symbol-at-point (thing-at-point 'symbol))) - (when symbol-at-point - (let* ((regexp (concat (regexp-quote symbol-at-point) "$")) - (matching-symbols (delq nil (mapcar (lambda (symbol) - (if (string-match regexp symbol) symbol)) - symbol-names)))) - (when matching-symbols - (sort matching-symbols (lambda (a b) (> (length a) (length b)))) - (mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names)))) - matching-symbols))))) - (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names)) - (position (cdr (assoc selected-symbol name-and-pos)))) - (goto-char position)))) - -(defun ido-goto-symbol (&optional symbol-list) - "Refresh imenu and jump to a place in the buffer using Ido." - (interactive) - (unless (featurep 'imenu) - (require 'imenu nil t)) - (cond - ((not symbol-list) - (let ((ido-mode ido-mode) - (ido-enable-flex-matching - (if (boundp 'ido-enable-flex-matching) - ido-enable-flex-matching t)) - name-and-pos symbol-names position) - (unless ido-mode - (ido-mode 1) - (setq ido-enable-flex-matching t)) - (while (progn - (imenu--cleanup) - (setq imenu--index-alist nil) - (ido-goto-symbol (imenu--make-index-alist)) - (setq selected-symbol - (ido-completing-read "Symbol? " symbol-names)) - (string= (car imenu--rescan-item) selected-symbol))) - (unless (and (boundp 'mark-active) mark-active) - (push-mark nil t nil)) - (setq position (cdr (assoc selected-symbol name-and-pos))) - (cond - ((overlayp position) - (goto-char (overlay-start position))) - (t - (goto-char position))))) - ((listp symbol-list) - (dolist (symbol symbol-list) - (let (name position) - (cond - ((and (listp symbol) (imenu--subalist-p symbol)) - (ido-goto-symbol symbol)) - ((listp symbol) - (setq name (car symbol)) - (setq position (cdr symbol))) - ((stringp symbol) - (setq name symbol) - (setq position - (get-text-property 1 'org-imenu-marker symbol)))) - (unless (or (null position) (null name) - (string= (car imenu--rescan-item) name)) - (add-to-list 'symbol-names (substring-no-properties name)) - (add-to-list 'name-and-pos (cons (substring-no-properties name) position)))))))) - -#+end_src - * isearch #+begin_src emacs-lisp (setq @@ -3241,8 +3152,8 @@ disabled cuz I have none yet (setq ac-sources (delq 'ac-source-dictionary ac-sources)) (highlight-symbol-mode) (make-local-variable 'column-number-mode) + ;; this says do autofilling using newcomment.el. The "only" is a misnomer. (set (make-local-variable 'comment-auto-fill-only-comments) t) - (auto-fill-mode t) (column-number-mode t) (turn-on-smartparens-mode) @@ -4335,10 +4246,10 @@ isearch-occur (isearch-toggle-regexp) (cond (isearch-regexp (global-set-key (kbd "C-r") 'isearch-backward-regexp) - (define-key global-map (kbd search-key) 'isearch-forward-regexp)) + (define-key global-map (kbd "") 'isearch-forward-regexp)) (t (global-set-key (kbd "C-r") 'isearch-backward) - (define-key global-map (kbd search-key) 'isearch-forward)))) + (define-key global-map (kbd "") 'isearch-forward)))) (define-key isearch-mode-map (kbd "M-r") 'my-isearch-toggle-regexp) #+end_src @@ -4659,9 +4570,9 @@ isearch isearch-forward #+begin_src emacs-lisp ;; explained in http://stackoverflow.com/questions/7411920/how-to-bind-search-and-search-repeat-to-c-f-in-emacs -(global-set-key (kbd search-key) 'isearch-forward) +(global-set-key (kbd "") 'isearch-forward) (define-key isearch-mode-map "\t" nil) -(define-key isearch-mode-map (kbd search-key) 'isearch-repeat-forward) +(define-key isearch-mode-map (kbd "") 'isearch-repeat-forward) ;; get rid of the standard completion binding, always use auto-complete ;; this didn't work very well ;;(global-set-key (kbd "TAB") 'auto-complete) @@ -4924,7 +4835,7 @@ modes like org-mode which have their own yank function." :END: shell #+begin_src emacs-lisp -(global-set-key (kbd shell-key) 'shell-wrap) +(global-set-key (kbd "") 'shell-wrap) #+end_src *** s-right arrow :PROPERTIES: @@ -4947,6 +4858,7 @@ new line #+begin_src emacs-lisp ;; todo, this doesn't set the keybind for the help minibuffer (when (boundp 'icomplete-minibuffer-map) + (define-key icomplete-minibuffer-map (kbd "C-j") 'exit-minibuffer) (define-key icomplete-minibuffer-map (kbd "") 'minibuffer-force-complete-and-exit)) @@ -4965,7 +4877,6 @@ new line (define-key ac-completing-map "\r" nil) (define-key minibuffer-local-map "\r" nil) (define-key minibuffer-local-map (kbd "") 'exit-minibuffer) -(define-key icomplete-minibuffer-map (kbd "C-j") 'exit-minibuffer) (define-key minibuffer-local-map (kbd "C-j") 'exit-minibuffer) (define-key minibuffer-local-must-match-map (kbd "C-j") 'exit-minibuffer) (define-key minibuffer-local-must-match-map "\r" nil) @@ -8914,7 +8825,9 @@ much, so the added hassle of having to set it within this file is worth the benefit of only having one concept in my mind. #+begin_src emacs-lisp (dolist - (r `((?i (file . ,"~/.emacs.d/my-init.org")) + (r `( + (?i (file . ,"~/.emacs.d/my-init.org")) + (?t (file . ,"/a/x.txt")) )) (set-register (car r) (cadr r))) #+end_src