Skip to content

Commit

Permalink
Few new things
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacy committed Jan 30, 2011
1 parent 02e6366 commit 8324826
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bookmarks
Expand Up @@ -4,9 +4,9 @@
;;; -*- End Of Bookmark File Format Version Stamp -*-
(("org-capture-last-stored"
(filename . "~/Dropbox/org/notes.gpg")
(front-context-string . "** To jest zajeb")
(rear-context-string . " :imlog:\n")
(position . 75947))
(front-context-string . "** Sprawdzanie c")
(rear-context-string . "2011-01-25 wto]\n")
(position . 74321))
("test-file"
(filename . "~/code/webapp/lib/profile_service/profile_service_test.rb")
(front-context-string . "require File.dir")
Expand Down
187 changes: 180 additions & 7 deletions init.el
Expand Up @@ -33,7 +33,7 @@
ad-do-it
(and line (goto-line line))))


(setq next-line-add-newlines t)
(setq cscope-do-not-update-database t
;; grep-find-template "find . -type f -print0 | xargs -0 -e grep -nH -e "
anything-sources
Expand All @@ -58,7 +58,88 @@
(setq cua-keep-region-after-copy t) ;; Standard Windows behaviour
(delete-selection-mode t)

(setq visible-bell t)
(subword-mode t)

(defvar smart-use-extended-syntax nil
"If t the smart symbol functionality will consider extended
syntax in finding matches, if such matches exist.")

(defvar smart-last-symbol-name ""
"Contains the current symbol name.
This is only refreshed when `last-command' does not contain
either `smart-symbol-go-forward' or `smart-symbol-go-backward'")

(make-local-variable 'smart-use-extended-syntax)

(defvar smart-symbol-old-pt nil
"Contains the location of the old point")

(defun smart-symbol-goto (name direction)
"Jumps to the next NAME in DIRECTION in the current buffer.
DIRECTION must be either `forward' or `backward'; no other option
is valid."

;; if `last-command' did not contain
;; `smart-symbol-go-forward/backward' then we assume it's a
;; brand-new command and we re-set the search term.
(unless (memq last-command '(smart-symbol-go-forward
smart-symbol-go-backward))
(setq smart-last-symbol-name name))
(setq smart-symbol-old-pt (point))
(message (format "%s scan for symbol \"%s\""
(capitalize (symbol-name direction))
smart-last-symbol-name))
(unless (catch 'done
(while (funcall (cond
((eq direction 'forward) ; forward
'search-forward)
((eq direction 'backward) ; backward
'search-backward)
(t (error "Invalid direction"))) ; all others
smart-last-symbol-name nil t)
(unless (memq (syntax-ppss-context
(syntax-ppss (point))) '(string comment))
(throw 'done t))))
(goto-char smart-symbol-old-pt)))

(defun smart-symbol-go-forward ()
"Jumps forward to the next symbol at point"
(interactive)
(smart-symbol-goto (smart-symbol-at-pt 'end) 'forward))

(defun smart-symbol-go-backward ()
"Jumps backward to the previous symbol at point"
(interactive)
(smart-symbol-goto (smart-symbol-at-pt 'beginning) 'backward))

(defun smart-symbol-at-pt (&optional dir)
"Returns the symbol at point and moves point to DIR (either `beginning' or `end') of the symbol.
If `smart-use-extended-syntax' is t then that symbol is returned
instead."
(with-syntax-table (make-syntax-table)
(if smart-use-extended-syntax
(modify-syntax-entry ?. "w"))
(modify-syntax-entry ?_ "w")
(modify-syntax-entry ?- "w")
;; grab the word and return it
(let ((word (thing-at-point 'word))
(bounds (bounds-of-thing-at-point 'word)))
(if word
(progn
(cond
((eq dir 'beginning) (goto-char (car bounds)))
((eq dir 'end) (goto-char (cdr bounds)))
(t (error "Invalid direction")))
word)
(error "No symbol found")))))

(global-set-key (kbd "M-n") 'smart-symbol-go-forward)
(global-set-key (kbd "M-p") 'smart-symbol-go-backward)

;; '(setq visible-bell t)
(show-paren-mode 1)
(fset 'yes-or-no-p 'y-or-n-p)
(tool-bar-mode -1)
Expand Down Expand Up @@ -279,18 +360,69 @@

(add-to-list 'load-path (concat dotfiles-dir "/color-theme-6.6.0"))

(load-file (concat imoryc-dir "/colors/color-theme-irblack.el"))
(load-file (concat imoryc-dir "/colors/color-theme-gruber-darker.el"))
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(color-theme-irblack)))
(color-theme-gruber-darker)))

(setq font-use-system-font t)

(global-set-key [C-tab] 'bs-show)
;; Moje funkcje


(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 name)
(add-to-list 'name-and-pos (cons name position))))))))

(global-set-key "\C-ci" 'ido-goto-symbol) ; or any key you see fit

(defun push-mark-no-activate ()
"Pushes `point' to `mark-ring' and does not activate the region
Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled"
Expand All @@ -313,10 +445,51 @@ This is the same as using \\[set-mark-command] with the prefix argument."
(re-search-forward note)
(point))


(require 'etags)
(defun ido-find-tag ()
"Find a tag using ido"
(interactive)
(tags-completion-table)
(let (tag-names)
(mapc (lambda (x)
(unless (integerp x)
(push (prin1-to-string x t) tag-names)))
tags-completion-table)
(find-tag (ido-completing-read "Tag: " tag-names))))

(defun ido-find-file-in-tag-files ()
(interactive)
(save-excursion
(let ((enable-recursive-minibuffers t))
(visit-tags-table-buffer))
(find-file
(expand-file-name
(ido-completing-read
"Project file: " (tags-table-files) nil t)))))

(global-set-key [remap find-tag] 'ido-find-tag)
(global-set-key (kbd "C-.") 'ido-find-file-in-tag-files)


(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)

;; get rid of `find-file-read-only' and replace it with something
;; more useful.
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)

;; enable recent files mode.
(recentf-mode t)

; 50 files ought to be enough.
(setq recentf-max-saved-items 50)

(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))

(add-hook 'before-save-hook 'whitespace-cleanup)

Expand Down
Empty file.

0 comments on commit 8324826

Please sign in to comment.