xcscope key rebinding in in conflict with emacs default - emacs

I have the following in my init.el but c-\ in emacs binds to input method. I don't use input method anyways so is there a way to disable c-\ not to bind to input method?
(add-to-list 'load-path "~/.emacs.d")
(require 'xcscope)
(setq cscope-do-not-update-database t)
(define-key cscope:map "\C-\\s" 'cscope-find-this-symbol)
(define-key cscope:map "\C-\\g" 'cscope-find-global-definition)
(define-key cscope:map "\C-\\d" 'cscope-find-called-functions)
(define-key cscope:map "\C-\\c" 'cscope-find-functions-calling-this-function)
(define-key cscope:map "\C-\\t" 'cscope-find-this-text-string)
(define-key cscope:map "\C-\\e" 'cscope-find-egrep-pattern)
(define-key cscope:map "\C-\\f" 'cscope-find-this-file)
(define-key cscope:map "\C-\\i" 'cscope-find-files-including-file)
(define-key cscope:map "\C-\\b" 'cscope-display-buffer)
(define-key cscope:map "\C-\\B" 'cscope-display-buffer-toggle)
(define-key cscope:map "\C-\\n" 'cscope-next-symbol)
(define-key cscope:map "\C-\\N" 'cscope-next-file)
(define-key cscope:map "\C-\\p" 'cscope-prev-symbol)
(define-key cscope:map "\C-\\P" 'cscope-prev-file)
(define-key cscope:map "\C-\\u" 'cscope-pop-mark)
(define-key cscope:map "\C-\\v" 'cscope-history-backward)
(define-key cscope:map "\C-\\V" 'cscope-history-forward)

Try this:
(global-unset-key (kbd "C-\\"))

Related

How to get rid of weird white bar in the minibuffer Emacs

I have this weird issue where whenever I type down :w or any other kind of command which can be used in vim's command mode (I am using evil-mode in emacs so that I can vim emulation) I always get this weird white cursor at the bottom of the minibuffer. Could you please tell me a way to get rid of this because it is really bugging me.
I thought that it may be useful if I included my init.el. If it is needed this is it:
(defun ali/initial-setup ()
"Basic Settings to make emacs usable"
(set-default-coding-systems 'utf-8)
(set-face-attribute 'default nil :font "Consolas" :height 120)
(setq scroll-margin 6)
(setq visible-bell 1)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse 't)
(setq scroll-step 3)
(setq-default indent-tabs-mode nil)
"Setting up fringes and truncated lines"
(global-visual-line-mode t)
(setq truncate-lines t)
(add-to-list 'default-frame-alist '(internal-border-width . 1))
(setq-default left-fringe-width 6)
"Making the line numbers wider"
(add-hook 'display-line-numbers-mode-hook '(lambda() (setq display-line-numbers-width 3)))
"Getting rid of autosave files and other stuff"
(setq make-lockfiles nil
make-backup-files nil)
(auto-save-mode -1)
"Making splits always be vertical by default"
(setq split-height-threshold nil
split-width-threshold 0)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq-default c-basic-offset 4
c-default-style "linux"))
(defun ali/brackets()
"Automatically completing brackets and pairs"
(show-paren-mode 1)
(electric-pair-mode 1)
(setq electric-pair-pairs
'((?\" . ?\")
(?\{ . ?\}))))
;; Setting up packages
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(require 'package)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(defvar packages-we-need '(org modus-themes evil ido))
(dolist (package packages-we-need)
(unless (package-installed-p 'package)
(package-install 'package)))
(defun ali/ido()
"Setting up ido mode"
(require 'ido)
(setq ido-create-new-buffer 'always)
"Making ido-mode work in M-x"
(global-set-key
"\M-x"
(lambda ()
(interactive)
(call-interactively
(intern
(ido-completing-read
"M-x "
(all-completions "" obarray 'commandp))))))
(ido-everywhere t)
(ido-mode 1))
(require 'modus-themes)
(load-theme 'modus-vivendi t)
(defun ali/evil()
(require 'evil)
"Making cursor always be a box"
(setq evil-insert-state-cursor 'box)
(evil-make-overriding-map ali-keymap 'normal 'motion)
(evil-mode 1))
(let ((ali-keymap (make-sparse-keymap)))
(define-key ali-keymap (kbd "C-h") 'evil-window-left)
(define-key ali-keymap (kbd "C-j") 'evil-window-down)
(define-key ali-keymap (kbd "C-k") 'evil-window-up)
(define-key ali-keymap (kbd "C-l") 'evil-window-right)
(define-key ali-keymap (kbd "M-d") '(lambda() (interactive) (execute-kbd-macro (read-kbd-macro "C-x d RET"))))
(define-key ali-keymap (kbd "C-p") 'ido-switch-buffer)
(define-key ali-keymap (kbd "C-f") 'ido-find-file)
(define-key ali-keymap (kbd "M-=") 'enlarge-window-horizontally)
(define-key ali-keymap (kbd "M--") 'shrink-window-horizontally)
(define-key ali-keymap (kbd "C-=") 'text-scale-increase)
(define-key ali-keymap (kbd "C--") 'text-scale-decrease)
(define-key ali-keymap (kbd "C-/") 'comment-line)
(define-key ali-keymap (kbd "C-S-i") 'display-line-numbers-mode)
(define-key ali-keymap (kbd "M-v") 'evil-window-vsplit)
(define-key ali-keymap (kbd "M-h") 'evil-window-split)
(define-key ali-keymap (kbd "C-S-h") 'help)
(define-key ali-keymap (kbd "C-d") 'kill-buffer)
(define-key ali-keymap (kbd "M-1") '(lambda() (interactive) (execute-kbd-macro (read-kbd-macro "M-x make-directory RET"))))
(defvar ali-keymap ali-keymap
"These are my keybindings"))
(define-minor-mode ali-keybindings-mode
nil
:global t
:lighter " keys"
:keymap ali-keymap)
(ali-keybindings-mode 1)
(ali/initial-setup)
(ali/evil)
(ali/brackets)
(ali/ido)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("27a1dd6378f3782a593cc83e108a35c2b93e5ecc3bd9057313e1d88462701fcd" "0feb7052df6cfc1733c1087d3876c26c66410e5f1337b039be44cb406b6187c6" "57e3f215bef8784157991c4957965aa31bac935aca011b29d7d8e113a652b693" "0f7fa4835d02a927d7d738a0d2d464c38be079913f9d4aba9c97f054e67b8db9" "ddff22007104a1317014e48ff3d4911a83771a4ccf57185ccebf7f91339dbfb8" default))
'(package-selected-packages '(geiser-stklos modus-themes evil)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
I solved removing where I wrote (setq-default left-fringe-width 6) and instead I added (add-to-list 'default-frame-alist '(left-fringe . 5))

Emacs, binding "C-c s" key to "<menu>" key

How to bind "C-c s" to "< menu >" key, so that I can use Cscope in emacs easily? My aim is to replace C-c s prefix with menu key.
Instead of pressing "C-c s g", I have to press "< menu > g" and
Instead of pressing "C-c s =", I have to press "< menu > =" and for remaining cscope bindings.
edit 1:
Well, I have already done this by binding each key separately to cscope functions. I was searching for more generic and smaller solution.
I have done it like this,
(define-key global-map [(menu) (s)] 'cscope-find-this-symbol)
(define-key global-map [(menu) (d)] 'cscope-find-global-definition)
(define-key global-map [(menu) (g)] 'cscope-find-global-definition)
(define-key global-map [(menu) (G)] 'cscope-find-global-definition-no-prompting)
(define-key global-map [(menu) (=)] 'cscope-find-assignments-to-this-symbol)
(define-key global-map [(menu) (c)] 'cscope-find-functions-calling-this-function)
(define-key global-map [(menu) (C)] 'cscope-find-called-functions)
(define-key global-map [(menu) (t)] 'cscope-find-this-text-string)
(define-key global-map [(menu) (e)] 'cscope-find-egrep-pattern)
(define-key global-map [(menu) (f)] 'cscope-find-this-file)
(define-key global-map [(menu) (i)] 'cscope-find-files-including-file)
;; --- (The '---' indicates that this line corresponds to a menu separator.)
(define-key global-map [(menu) (b)] 'cscope-display-buffer)
(define-key global-map [(menu) (B)] 'cscope-display-buffer-toggle)
(define-key global-map [(menu) (n)] 'cscope-history-forward-line-current-result)
(define-key global-map [(menu) (N)] 'cscope-history-forward-file-current-result)
(define-key global-map [(menu) (p)] 'cscope-history-backward-line-current-result)
(define-key global-map [(menu) (P)] 'cscope-history-backward-file-current-result)
(define-key global-map [(menu) (u)] 'cscope-pop-mark)
;; ---
(define-key global-map [(menu) (a)] 'cscope-set-initial-directory)
(define-key global-map [(menu) (A)] 'cscope-unset-initial-directory)
;; ---
(define-key global-map [(menu) (L)] 'cscope-create-list-of-files-to-index)
(define-key global-map [(menu) (I)] 'cscope-index-files)
(define-key global-map [(menu) (E)] 'cscope-edit-list-of-files-to-index)
(define-key global-map [(menu) (W)] 'cscope-tell-user-about-directory)
(define-key global-map [(menu) (S)] 'cscope-tell-user-about-directory)
(define-key global-map [(menu) (T)] 'cscope-tell-user-about-directory)
(define-key global-map [(menu) (D)] 'cscope-dired-directory)

Rebind digits for normal mode in evil

Is it possible to rebind digits. That, for example, "5" is "$", and "%" is "5"?
In evil-maps.el digits are defined like this.
(define-key evil-motion-state-map "1" 'digit-argument)
(define-key evil-motion-state-map "2" 'digit-argument)
...
I tried the answer of #ChillarAnand
(add-hook 'evil-mode-hook 'evil-mode-bindings)
(defun evil-mode-bindings ()
"Bind symbols to digits."
(define-key key-translation-map (kbd "%") "5")
(define-key key-translation-map (kbd "*") "8")
)
(define-key evil-normal-state-map "5" 'evil-beginning-of-line)
(define-key evil-normal-state-map "8" 'evil-end-of-line)
But Shift-5 still does not behave like 5, the same is true for 8.
Is it possible to fix it for the config above?
The same stands for #tarblet solution.
What I use as a test is a sequence Shift-5, G.
Quite a hacky solution, but it should do what you want:
(defun capslock-digit-argument-fn (digit)
`(lambda (arg)
(interactive "P")
(setq last-command-event (+ ,digit ?0))
(digit-argument arg)))
(define-key evil-motion-state-map "!" (capslock-digit-argument-fn 1))
(define-key evil-motion-state-map "#" (capslock-digit-argument-fn 2))
(define-key evil-motion-state-map "#" (capslock-digit-argument-fn 3))
(define-key evil-motion-state-map "$" (capslock-digit-argument-fn 4))
(define-key evil-motion-state-map "%" (capslock-digit-argument-fn 5))
(define-key evil-motion-state-map "^" (capslock-digit-argument-fn 6))
(define-key evil-motion-state-map "&" (capslock-digit-argument-fn 7))
(define-key evil-motion-state-map "*" (capslock-digit-argument-fn 8))
(define-key evil-motion-state-map "(" (capslock-digit-argument-fn 9))
It rebinds the variable which digit-argument looks at when trying to figure out which key was pressed. If you don't mind ) not behaving exactly like 0 (no jumping to beginning of line, only working as digit arg) you could set it as well.
Ofcourse, anything is possible in emacs :)
Add this piece of code to you config.
(add-hook 'evil-mode-hook 'evil-mode-bindings)
(defun evil-mode-bindings ()
"Bind symbols to digits."
(define-key key-translation-map (kbd "!") (kbd "1"))
(define-key key-translation-map (kbd "#") (kbd "2"))
(define-key key-translation-map (kbd "#") (kbd "3"))
(define-key key-translation-map (kbd "$") (kbd "4"))
(define-key key-translation-map (kbd "%") (kbd "5"))
(define-key key-translation-map (kbd "^") (kbd "6"))
(define-key key-translation-map (kbd "&") (kbd "7"))
(define-key key-translation-map (kbd "*") (kbd "8"))
(define-key key-translation-map (kbd "(") (kbd "9"))
(define-key key-translation-map (kbd ")") (kbd "0")))
Whenever You enter evil mode, evil-mode-hook runs evil-mode-bindings function. This function binds, symbols to corresponding digits.
Update:
As #npostavs mentioned, You can also use this
(add-hook 'evil-mode-hook 'evil-mode-bindings)
(defun evil-mode-bindings ()
"Bind symbols to digits."
(define-key key-translation-map (kbd "!") "1")
(define-key key-translation-map (kbd "#") "2")
(define-key key-translation-map (kbd "#") "3")
(define-key key-translation-map (kbd "$") "4")
(define-key key-translation-map (kbd "%") "5")
(define-key key-translation-map (kbd "^") "6")
(define-key key-translation-map (kbd "&") "7")
(define-key key-translation-map (kbd "*") "8")
(define-key key-translation-map (kbd "(") "9")
(define-key key-translation-map (kbd ")") "0"))

in Emacs, how to change key bindings for orgstruct-mode?

I use custom key bindings for org-mode:
(eval-after-load "org"
'(progn
(define-key org-mode-map (kbd "<M-S-left>") nil)
(define-key org-mode-map (kbd "<M-S-right>") nil)
(define-key org-mode-map (kbd "<M-S-up>") nil)
(define-key org-mode-map (kbd "<M-S-down>") nil)
(define-key org-mode-map (kbd "<M-left>") nil)
(define-key org-mode-map (kbd "<M-right>") nil)
(define-key org-mode-map (kbd "<M-right>") nil)
(define-key org-mode-map [C-S-right] 'org-shiftmetaright)
(define-key org-mode-map [C-S-left] 'org-shiftmetaleft)
(define-key org-mode-map [C-right] 'org-metaright)
(define-key org-mode-map [C-left] 'org-metaleft)
(define-key org-mode-map [C-up] 'org-metaup)
(define-key org-mode-map [C-down] 'org-metadown)
(define-key org-mode-map [C-S-return] 'org-insert-todo-heading)
))
I'd like to use these same key bindings in orgstruct-mode, which I run overtop message-mode. What I tried doesn't work:
(define-key orgstruct-mode-map (kbd "<M-S-left>") nil)
(define-key orgstruct-mode-map (kbd "<M-S-right>") nil)
(define-key orgstruct-mode-map (kbd "<M-S-up>") nil)
(define-key orgstruct-mode-map (kbd "<M-S-down>") nil)
(define-key orgstruct-mode-map (kbd "<M-left>") nil)
(define-key orgstruct-mode-map (kbd "<M-right>") nil)
(define-key orgstruct-mode-map (kbd "<M-up>") nil)
(define-key orgstruct-mode-map (kbd "<M-down>") nil)
How can I change the key map for orgstruct-mode?
Defining a key to nil unbinds it. By unbinding a key in orgstruct-mode-map (the minor mode), you've exposed the message-mode-map (the major mode) bindings. You can override the message-mode-map keybindings by actively binding those keys in orgstruct-mode-map, but if you want to unbind them, you'll need to unbind the keys in message-mode-map as well.
Here's a way to unbind all of those keys in both maps:
(cl-dolist (map '(message-mode-map orgstruct-mode-map))
(cl-dolist (key '("<M-S-left>" "<M-S-right>" "<M-S-up>" "<M-S-down>"
"<M-left>" "<M-right>" "<M-up>" "<M-down>"))
(define-key (eval map) (kbd key) nil)))

Can't write capital M

I suppose my problem is pretty obvious, but I don't know Lisp and can't figure it out. Every time I try to write a capital "M" in a python file it won't work (It seems to think that's a start of a shortcut). My guess is that's somewhere in a module or my .emacs file it tries to bind something to Alt + something. But instead it binds it to capital M something. Here's my .emacs file (of which I copied most of it from the net):
; load-path setting is only needed if the directory you put
; weblogger.el in isn't already in your load-path
(add-to-list 'load-path "~/.emacs.d/")
; Remap Ctrl-tab to M-Tab
(define-key function-key-map [(control tab)] [?\M-\t])
(require 'ipython)
(define-key py-mode-map (kbd "M-") 'anything-ipython-complete)
(define-key py-shell-map (kbd "M-") 'anything-ipython-complete)
(define-key py-mode-map (kbd "C-c M") 'anything-ipython-import-modules-from-buffer)
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(require 'python-pep8)
(require 'python-pylint)
(require 'lambda-mode)
(add-hook 'python-mode-hook #'lambda-mode 1)
(require 'comint)
(define-key comint-mode-map (kbd "M-") 'comint-next-input)
(define-key comint-mode-map (kbd "M-") 'comint-previous-input)
(define-key comint-mode-map [down] 'comint-next-matching-input-from-input)
(define-key comint-mode-map [up] 'comint-previous-matching-input-from-input)
(autoload 'pylookup-lookup "pylookup")
(autoload 'pylookup-update "pylookup")
(setq pylookup-program "~/.emacs.d/pylookup/pylookup.py")
(setq pylookup-db-file "~/.emacs.d/pylookup/pylookup.db")
(global-set-key "\C-ch" 'pylookup-lookup)
(autoload 'autopair-global-mode "autopair" nil t)
(autopair-global-mode)
(add-hook 'lisp-mode-hook
#'(lambda () (setq autopair-dont-activate t)))
(add-hook 'python-mode-hook
#'(lambda ()
(push '(?' . ?')
(getf autopair-extra-pairs :code))
(setq autopair-handle-action-fns
(list #'autopair-default-handle-action
#'autopair-python-triple-quote-action))))
(require 'python-pep8)
(require 'python-pylint)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(autoload 'pylookup-lookup "pylookup")
(autoload 'pylookup-update "pylookup")
(setq pylookup-program "~/.emacs.d/pylookup/pylookup.py")
(setq pylookup-db-file "~/.emacs.d/pylookup/pylookup.db")
(global-set-key "\C-ch" 'pylookup-lookup)
;; Initialize Rope
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)
(require 'auto-complete)
(global-auto-complete-mode t)
;(when (require 'auto-complete nil t)
; (require 'auto-complete-yasnippet)
; (require 'auto-complete-python)
; (require 'auto-complete-css)
; (require 'auto-complete-cpp)
; (require 'auto-complete-emacs-lisp)
; (require 'auto-complete-semantic)
; (require 'auto-complete-gtags))
; (global-auto-complete-mode t)
; (setq ac-auto-start 3)
; (setq ac-dwim t)
; (set-default 'ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-words-in-buffer ac-source-files-in-current-dir ac-source-symbols))
; (load-library "init_python")
Any idea where I should start looking for the problem? A simple search or any other way to debug the files in the .emacs-directory?
This looks wrong to me:
(define-key py-mode-map (kbd "M-") 'anything-ipython-complete)
(define-key py-shell-map (kbd "M-") 'anything-ipython-complete)
(define-key comint-mode-map (kbd "M-") 'comint-next-input)
(define-key comint-mode-map (kbd "M-") 'comint-previous-input)
kbd expect a full binding, but you're trying to bind M-
to some functions. I suspect a letter is missing.
i.e.
(define-key py-mode-map (kbd "M-TAB") 'anything-ipython-complete)
Here, M stands for META which is usually bound to ALT
or ESC.
By the way, you can do XC-h to see
minor mode bindings starting with X.