From 136128abd18ca5d0be409473c459ef7ed78031da Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 27 May 2011 22:57:40 +0200 Subject: Removed c-eldoc and linum-ex I didn't use c-eldoc and linum-ex only seemed to cause warnings to show up when loading files, not improve any speed. --- emacs.d/10-settings.el | 1 + emacs.d/20-c-eldoc.el | 6 - emacs.d/20-linum-ex.el | 3 - emacs.d/40-c-mode.el | 0 emacs.d/elisp/c-eldoc.el | 304 ---------------------------------------------- emacs.d/elisp/linum-ex.el | 287 ------------------------------------------- 6 files changed, 1 insertion(+), 600 deletions(-) delete mode 100644 emacs.d/20-c-eldoc.el delete mode 100644 emacs.d/20-linum-ex.el delete mode 100644 emacs.d/40-c-mode.el delete mode 100644 emacs.d/elisp/c-eldoc.el delete mode 100644 emacs.d/elisp/linum-ex.el (limited to 'emacs.d') diff --git a/emacs.d/10-settings.el b/emacs.d/10-settings.el index 4048bf1..5253cd1 100644 --- a/emacs.d/10-settings.el +++ b/emacs.d/10-settings.el @@ -24,6 +24,7 @@ (scroll-bar-mode -1) ; no scrollbars (line-number-mode -1) ; don't show line number in ; splitter +(global-linum-mode t) ; Show line numbers in gutter (column-number-mode t) ; show column number in splitter (global-font-lock-mode t) ; show syntax highlighting, old (delete-selection-mode t) ; delete selection upon typing diff --git a/emacs.d/20-c-eldoc.el b/emacs.d/20-c-eldoc.el deleted file mode 100644 index 5f01f6b..0000000 --- a/emacs.d/20-c-eldoc.el +++ /dev/null @@ -1,6 +0,0 @@ -(setq c-eldoc-includes "`pkg-config x11 --cflags` -I./ -I../") -(load "c-eldoc") -(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode) -(add-hook 'php-mode-hook - (lambda () - (eldoc-mode -1))) diff --git a/emacs.d/20-linum-ex.el b/emacs.d/20-linum-ex.el deleted file mode 100644 index 886b0f8..0000000 --- a/emacs.d/20-linum-ex.el +++ /dev/null @@ -1,3 +0,0 @@ -(require 'linum-ex) -(global-linum-mode 1) -(setq linum-delay 0.2) diff --git a/emacs.d/40-c-mode.el b/emacs.d/40-c-mode.el deleted file mode 100644 index e69de29..0000000 diff --git a/emacs.d/elisp/c-eldoc.el b/emacs.d/elisp/c-eldoc.el deleted file mode 100644 index 732d00d..0000000 --- a/emacs.d/elisp/c-eldoc.el +++ /dev/null @@ -1,304 +0,0 @@ -;;; c-eldoc.el --- helpful description of the arguments to C functions - -;; Copyright (C) 2004 Paul Pogonyshev -;; Copyright (C) 2004, 2005 Matt Strange -;; Copyright (C) 2010 Nathaniel Flath - -;; This file is NOT a part of GNU Emacs - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2 of the -;; License, or (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program; if not, write to the Free Software -;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -;; USA - -;;; Commentary: - -;; To enable: put the following in your .emacs file: -;; -;; (add-hook 'c-mode-hook 'c-turn-on-eldoc-mode) - -;; Nathaniel has submitted a caching patch to make this workable on large projects "like the emacs -;; codebase" -;; v0.5 01/02/2010 - -;; Provides helpful description of the arguments to C functions. -;; Uses child process grep and preprocessor commands for speed. -;; v0.4 01/16/2005 - -;; Your improvements are appreciated: I am no longer maintaining this code -;; m_strange at mail dot utexas dot edu. Instead, direct all requests to -;; flat0103@gmail.com - -;;; Code: - -(require 'eldoc) -;; without this, you can't compile this file and have it work properly -;; since the `c-save-buffer-state' macro needs to be known as such -(require 'cc-defs) -(require 'cl) - -;; make sure that the opening parenthesis in C will work -(eldoc-add-command 'c-electric-paren) - -;;if cache.el isn't loaded, define the cache functions -(unless (fboundp 'cache-make-cache) - (defun* cache-make-cache (init-fun test-fun cleanup-fun - &optional &key - (test #'eql) - (size 65) - (rehash-size 1.5) - (rehash-threshold 0.8) - (weakness nil)) - "Creates a cached hash table. This is a hash table where -elements expire at some condition, as specified by init-fun and -test-fun. The three arguments do as follows: - -init-fun is a function that is called when a new item is inserted -into the cache. - -test-fun is a function that is called when an item in the cache -is looked up. It takes one argument, and will be passed the -result of init-fun that was generated when the item was inserted -into the cache. - -cleanup-fun is called when an item is removed from the hash -table. It takes one argument, the value of the key-value pair -being deleted. - -Note that values are only deleted from the cache when accessed. - -This will return a list of 4 elements: a has table and the 3 -arguments. All hash-table functions will work on the car of this -list, although if accessed directly the lookups will return a pair -(value, (init-fun)). - -The keyword arguments are the same as for make-hash-table and are applied -to the created hash table." - (list (make-hash-table :test test - :size size - :rehash-size rehash-size - :rehash-threshold rehash-threshold - :weakness weakness) init-fun test-fun cleanup-fun)) - - (defun cache-gethash (key cache) - "Retrieve the value corresponding to key from cache." - (let ((keyval (gethash key (car cache) ))) - (if keyval - (let ((val (car keyval)) - (info (cdr keyval))) - (if (funcall (caddr cache) info) - (progn - (remhash key (car cache)) - (funcall (cadddr cache) val) - nil) - val))))) - - (defun cache-puthash (key val cache) - "Puts the key-val pair into cache." - (puthash key - (cons val (funcall (cadr cache))) - (car cache)))) - - -;; if you've got a non-GNU preprocessor with funny options, set these -;; variables to fix it -(defvar c-eldoc-cpp-macro-arguments "-dD -w -P") -(defvar c-eldoc-cpp-normal-arguments "-w -P") -(defvar c-eldoc-cpp-command "/lib/cpp ") -(defvar c-eldoc-includes - "`pkg-config gtk+-2.0 --cflags` -I./ -I../ " - "List of commonly used packages/include directories - For - example, SDL or OpenGL. This shouldn't slow down cpp, even if - you've got a lot of them.") - -(defvar c-eldoc-reserved-words - (list "if" "else" "switch" "while" "for" "sizeof") - "List of commands that eldoc will not check.") - - -(defvar c-eldoc-buffer-regenerate-time - 120 - "Time to keep a preprocessed buffer around.") - -(defun c-eldoc-time-diff (t1 t2) - "Return the difference between the two times, in seconds. -T1 and T2 are time values (as returned by `current-time' for example)." - ;; Pacify byte-compiler with `symbol-function'. - (time-to-seconds (subtract-time t1 t2))) - -(defun c-eldoc-time-difference (old-time) - "Returns whether or not old-time is less than c-eldoc-buffer-regenerate-time seconds ago." - (> (c-eldoc-time-diff (current-time) old-time) c-eldoc-buffer-regenerate-time)) - -(defun c-eldoc-cleanup (preprocessed-buffer) - (kill-buffer preprocessed-buffer)) - -(defvar c-eldoc-buffers - (cache-make-cache #'current-time #'c-eldoc-time-difference #'c-eldoc-cleanup) - "Cache of buffer->preprocessed file used to speed up finding arguments") - -(defun c-turn-on-eldoc-mode () - "Enable c-eldoc-mode" - (interactive) - (set (make-local-variable 'eldoc-documentation-function) - 'c-eldoc-print-current-symbol-info) - (turn-on-eldoc-mode)) - -;; call the preprocessor on the current file -;; -;; run cpp the first time to get macro declarations, the second time -;; to get normal function declarations -(defun c-eldoc-get-buffer (function-name) - "Call the preprocessor on the current file" -;; run the first time for macros - (let ((output-buffer (cache-gethash (current-buffer) c-eldoc-buffers))) - (if output-buffer output-buffer - (let* ((this-name (concat "*" buffer-file-name "-preprocessed*")) - (preprocessor-command (concat c-eldoc-cpp-command " " - c-eldoc-cpp-macro-arguments " " - c-eldoc-includes " " - buffer-file-name)) - (cur-buffer (current-buffer)) - (output-buffer (generate-new-buffer this-name))) - (bury-buffer output-buffer) - (call-process-shell-command preprocessor-command nil output-buffer nil) - ;; run the second time for normal functions - (setq preprocessor-command (concat c-eldoc-cpp-command " " - c-eldoc-cpp-normal-arguments " " - c-eldoc-includes " " - buffer-file-name)) - (call-process-shell-command preprocessor-command nil output-buffer nil) - (cache-puthash cur-buffer output-buffer c-eldoc-buffers) - output-buffer)))) - -(defun c-eldoc-function-and-argument (&optional limit) - "Finds the current function and position in argument list." - (let* ((literal-limits (c-literal-limits)) - (literal-type (c-literal-type literal-limits))) - (save-excursion - ;; if this is a string, move out to function domain - (when (eq literal-type 'string) - (goto-char (car literal-limits)) - (setq literal-type nil)) - (if literal-type - nil - (c-save-buffer-state ((argument-index 1)) - (while (or (eq (c-forward-token-2 -1 t limit) 0) - (when (eq (char-before) ?\[) - (backward-char) - t)) - (when (eq (char-after) ?,) - (setq argument-index (1+ argument-index)))) - (c-backward-syntactic-ws) - (when (eq (char-before) ?\() - (backward-char) - (c-forward-token-2 -1) - (when (looking-at "[a-zA-Z_][a-zA-Z_0-9]*") - (cons (buffer-substring-no-properties - (match-beginning 0) (match-end 0)) - argument-index)))))))) - -(defun c-eldoc-format-arguments-string (arguments index) - "Formats the argument list of a function." - (let ((paren-pos (string-match "(" arguments)) - (pos 0)) - (when paren-pos - (setq arguments (replace-regexp-in-string "\\\\?[[:space:]\\\n]" - " " - (substring arguments paren-pos)) - arguments (replace-regexp-in-string "\\s-+" " " arguments) - arguments (replace-regexp-in-string " *, *" ", " arguments) - arguments (replace-regexp-in-string "( +" "(" arguments) - arguments (replace-regexp-in-string " +)" ")" arguments)) - ;; find the correct argument to highlight, taking `...' - ;; arguments into account - (while (and (> index 1) - pos - (not (string= (substring arguments (+ pos 2) (+ pos 6)) - "...)"))) - (setq pos (string-match "," arguments (1+ pos)) - index (1- index))) - ;; embolden the current argument - (when (and pos - (setq pos (string-match "[^ ,()]" arguments pos))) - (add-text-properties pos (string-match "[,)]" arguments pos) - '(face bold) arguments)) - arguments))) - -(defun c-eldoc-print-current-symbol-info () - "Returns documentation string for the current symbol." - (let* ((current-function-cons (c-eldoc-function-and-argument (- (point) 1000))) - (current-function (car current-function-cons)) - (current-function-regexp (concat "[ \t\n]+[*]*" current-function "[ \t\n]*(")) - (current-macro-regexp (concat "#define[ \t\n]+[*]*" current-function "[ \t\n]*(")) - (current-buffer (current-buffer)) - (tag-buffer) - (function-name-point) - (arguments) - (type-face 'font-lock-type-face)) - (when (and current-function - (not (member current-function c-eldoc-reserved-words))) - (when (setq tag-buffer (c-eldoc-get-buffer current-function)) - ;; setup the buffer - (set-buffer tag-buffer) - (goto-char (point-min)) - (prog1 - ;; protected regexp search - (when (condition-case nil - (progn - (if (not (re-search-forward current-macro-regexp (point-max) t)) - (re-search-forward current-function-regexp)) - t) - (error (prog1 nil - (message "Function doesn't exist...")))) - ;; move outside arguments list - (search-backward "(") - (c-skip-ws-backward) - (setq function-name-point (point)) - (forward-sexp) - (setq arguments (buffer-substring-no-properties - function-name-point (point))) - (goto-char function-name-point) - (backward-char (length current-function)) - (c-skip-ws-backward) - (setq function-name-point (point)) - (search-backward-regexp "[};/#]" (point-min) t) - ;; check for macros - (if (= (char-after) ?#) - (let ((is-define (looking-at "#[[:space:]]*define")) - (preprocessor-point (point))) - (while (prog2 (end-of-line) - (= (char-before) ?\\) - (forward-char))) - (when (and is-define (> (point) function-name-point)) - (goto-char preprocessor-point) - (setq type-face 'font-lock-preprocessor-face))) - (forward-char) - (when (looking-back "//") - (end-of-line))) - (c-skip-ws-forward) - ;; colorize - (concat (propertize (buffer-substring-no-properties - (point) - function-name-point) - 'face type-face) - " " - (propertize current-function - 'face 'font-lock-function-name-face) - " " - (c-eldoc-format-arguments-string arguments - (cdr current-function-cons)))) - (set-buffer current-buffer)))))) - -(provide 'c-eldoc) -;;; c-eldoc.el ends here diff --git a/emacs.d/elisp/linum-ex.el b/emacs.d/elisp/linum-ex.el deleted file mode 100644 index 9cb3c6b..0000000 --- a/emacs.d/elisp/linum-ex.el +++ /dev/null @@ -1,287 +0,0 @@ -;;; linum-ex.el --- Display line numbers to the left of buffers - -;; originally derived from linum.el, which is -;; Copyright (C) 2007, 2008 Markus Triska - -;; modifications in linum-ex.el provided by: Dino Chiesa - -;; Author: Markus Triska -;; Last saved: <2011-May-23 12:47:18> -;; -;; Keywords: convenience - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; Display line numbers for the current buffer. Copy linum-ex.el to your -;; load-path and add to your .emacs: - -;; (require 'linum-ex) - -;; Then toggle display of line numbers with M-x linum-mode. To enable -;; line numbering in all buffers, use M-x global-linum-mode. - -;; ======================================================= -;; -;; Dino Chiesa Mon, 23 May 2011 12:00 -;; -;; notes on changes. -;; -;; The problem with the original linum module is that it updated the -;; line numbers after every scroll and possibly every command. This -;; works for small files but not for files with 100,000+ lines. Even -;; with linum-delay turned on, linum had the effect of "Freezing" the -;; display when the user was continuously scrolling. It also introduced -;; noticeable delays when scrolling only momentarily. -;; -;; One idea for working around that is to use run-with-idle-timer, and -;; only update the line numbers when emacs is idle. One can set a single -;; timer, for, say 0.1s, and then when emacs goes idle for that period, -;; the line numbers will be updated. Seems like the perfect fit, -;; but there's a problem: a timer created via run-with-idle-timer -;; gets canceled after being delayed 10 times. -;; -;; So if the after-scroll event sets up a timer via run-with-idle-timer, -;; only when no timer has been set, the timer may get canceled silently, -;; by timer.el . Look at `timer-max-repeats'. -;; -;; This happens if emacs is busy for 1s, as for example when the user is -;; holding pgdn to continuously scroll through a large document. If the -;; timer doesn't fire, then the line numbers don't ever get updated. -;; -;; To avoid that pitfall, this code can set run-with-idle-timer for -;; every scroll event, and handle the delay explicitly, right here. The -;; way to do it is, within the after-scroll event, store the "last -;; scrolled" time, and then call `run-with-idle-timer'. There may be -;; other outstanding timer events, but we don't care. In the function -;; that gets called when the timer fires, check to see if a reasonable -;; interval (Say 0.1s) has elapsed since the last scroll event. If so, -;; do linum-update. If not, it means scrolling is still happening, so, -;; do nothing. All this applies only if linum-delay is non-nil. -;; -;; The result is that timers fire constantly while the user is -;; continuously scrolling, but the line numbers get updated only after -;; the user stops scrolling. The user experiences no delay while -;; scrolling, but (unfortunately) gets no line numbers either. The user -;; sees updated line numbers immediately when he stops. -;; -;; ======================================================= - - -;;; Code: - -(require 'timer) - -(defconst linum-version "0.991") - -(defvar linum-overlays nil "Overlays used in this buffer.") -(defvar linum-available nil "Overlays available for reuse.") -(defvar linum-before-numbering-hook nil - "Functions run in each buffer before line numbering starts.") - -(mapc #'make-variable-buffer-local '(linum-overlays linum-available)) - -(defgroup linum nil - "Show line numbers to the left of buffers" - :group 'convenience) - -;;;###autoload -(defcustom linum-format 'dynamic - "Format used to display line numbers. Either a format string -like \"%7d\", 'dynamic to adapt the width as needed, or a -function that is called with a line number as its argument and -should evaluate to a string to be shown on that line. See also -`linum-before-numbering-hook'." - :group 'linum - :type 'sexp) - -(defface linum - '((t :inherit (shadow default))) - "Face for displaying line numbers in the display margin." - :group 'linum) - -(defcustom linum-eager t - "Whether line numbers should be updated after each command. -The conservative setting `nil' might miss some buffer changes, -and you have to scroll or press C-l to update the numbers." - :group 'linum - :type 'boolean) - -(defcustom linum-delay nil - "Delay updates to give Emacs a chance for other changes." - :group 'linum - :type 'boolean) - -(defvar linum--delay-time 0.1 - "Delay time. See also `linum-delay'") - -(defvar linum--last-scroll nil - "Time of last scroll event. See also `linum-delay'") - -(defvar linum--last-cmd nil - "Time of last command. See also `linum-delay'") - -(defvar linum--win nil - "Window of the last scroll event. See also `linum-delay'") - - -;;;###autoload -(define-minor-mode linum-mode - "Toggle display of line numbers in the left marginal area." - :lighter "" ; for desktop.el - (if linum-mode - (progn - (if linum-eager - (add-hook 'post-command-hook 'linum-post-command) - (add-hook 'after-change-functions 'linum-after-change nil t)) - (add-hook 'window-scroll-functions 'linum-after-scroll nil t) - ;; mistake in Emacs: window-size-change-functions cannot be local - (add-hook 'window-size-change-functions 'linum-after-size) - (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t) - (add-hook 'window-configuration-change-hook - 'linum-after-config nil t) - (set (make-local-variable 'linum--win) nil) - (set (make-local-variable 'linum--last-scroll) nil) - (set (make-local-variable 'linum--last-cmd) nil) - (linum-update-current)) - (remove-hook 'post-command-hook 'linum-post-command t) - (remove-hook 'window-size-change-functions 'linum-after-size) - (remove-hook 'window-scroll-functions 'linum-after-scroll t) - (remove-hook 'after-change-functions 'linum-after-change t) - (remove-hook 'window-configuration-change-hook 'linum-after-config t) - (remove-hook 'change-major-mode-hook 'linum-delete-overlays t) - (linum-delete-overlays))) - -;;;###autoload -(define-globalized-minor-mode global-linum-mode linum-mode linum-on) - -(defun linum-on () - (unless (minibufferp) - (linum-mode 1))) - -(defun linum-delete-overlays () - "Delete all overlays displaying line numbers for this buffer." - (mapc #'delete-overlay linum-overlays) - (setq linum-overlays nil) - (dolist (w (get-buffer-window-list (current-buffer) nil t)) - (set-window-margins w 0))) - -(defun linum-update-current () - "Update line numbers for the current buffer." - (linum-update (current-buffer))) - -(defun linum-update (buffer) - "Update line numbers for all windows displaying BUFFER." - (with-current-buffer buffer - (when linum-mode - (setq linum-available linum-overlays) - (setq linum-overlays nil) - (save-excursion - (mapc #'linum-update-window - (get-buffer-window-list buffer nil 'visible))) - (mapc #'delete-overlay linum-available) - (setq linum-available nil - linum--last-cmd nil - linum--last-scroll nil)))) - - -(defun linum-update-window (win) - "Update line numbers for the portion visible in window WIN." - (goto-char (window-start win)) - (let ((line (line-number-at-pos)) - (limit (window-end win t)) - (fmt (cond ((stringp linum-format) linum-format) - ((eq linum-format 'dynamic) - (let ((w (length (number-to-string - (count-lines (point-min) (point-max)))))) - (concat "%" (number-to-string w) "d"))))) - (width 0)) - (run-hooks 'linum-before-numbering-hook) - ;; Create an overlay (or reuse an existing one) for each - ;; line visible in this window, if necessary. - (while (and (not (eobp)) (<= (point) limit)) - (let* ((str (if fmt - (propertize (format fmt line) 'face 'linum) - (funcall linum-format line))) - (visited (catch 'visited - (dolist (o (overlays-in (point) (point))) - (when (string= (overlay-get o 'linum-str) str) - (unless (memq o linum-overlays) - (push o linum-overlays)) - (setq linum-available (delete o linum-available)) - (throw 'visited t)))))) - (setq width (max width (length str))) - (unless visited - (let ((ov (if (null linum-available) - (make-overlay (point) (point)) - (move-overlay (pop linum-available) (point) (point))))) - (push ov linum-overlays) - (overlay-put ov 'before-string - (propertize " " 'display `((margin left-margin) ,str))) - (overlay-put ov 'linum-str str)))) - (forward-line) - (setq line (1+ line))) - (set-window-margins win width))) - -(defun linum-after-change (beg end len) - ;; update overlays on deletions, and after newlines are inserted - (when (or (= beg end) - (= end (point-max)) - ;; TODO: use string-match-p with CVS or new release - (string-match "\n" (buffer-substring-no-properties beg end))) - (linum-update-current))) - -(defun linum--after-scroll-fired () - (if linum--last-scroll - (let ((now (current-time)) - (one-moment-after-scroll (timer-relative-time linum--last-scroll linum--delay-time))) - (if (time-less-p one-moment-after-scroll now) - (linum-update linum--win))))) - -(defun linum-after-scroll (win start) - (if linum-delay - (progn - (setq linum--win (window-buffer win)) - (setq linum--last-scroll (current-time)) - (run-with-idle-timer linum--delay-time nil 'linum--after-scroll-fired)) - (linum-update (window-buffer win)))) - - -(defun linum--post-command-fired () - (if linum--last-cmd - (let ((now (current-time)) - (one-moment-after-cmd (timer-relative-time linum--last-cmd linum--delay-time))) - (if (time-less-p one-moment-after-cmd now) - (linum-update-current))))) - -(defun linum-post-command () - (if linum-delay - (progn - (setq linum--win (window-buffer win)) - (setq linum--last-cmd (current-time)) - (run-with-idle-timer linum--delay-time nil 'linum--post-command-fired)) - (linum-update-current))) - -(defun linum-after-size (frame) - (linum-after-config)) - -(defun linum-after-config () - (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visible)) - - -(provide 'linum-ex) -;;; linum-ex.el ends here -- cgit v1.2.3-54-g00ecf