What is the folding method corresponding to {{{ in Emacs? - emacs

I have used the following as comments in my .emacs
// {{{
// }}}
My .emacs
;; Basic Characteristics// {{{*/
(setq c-basic-offset 4) ; indents 4 chars
(setq tab-width 4) ; and 4 char wide for TAB
(setq indent-tabs-mode nil) ; And force use of spaces
(turn-on-font-lock) ; same as syntax on in Vim
(setq inhibit-splash-screen t) ; hide welcome screen// }}}*/
;;;; For Emacs' org -mode// {{{*/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The following lines are always needed. Choose your own keys.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-font-lock-mode 1) ; for all buffers
(add-hook 'org-mode-hook 'turn-on-font-lock) ; Org buffers only
;; This is needed for Emacs 22, not for 23
(transient-mark-mode 1)
;; To load Lisp files
;; includes only one folder
;; (add-to-list 'load-path "~/.lisp")
;// }}}*/
;; to include all subdirectories too// {{{*/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 1. color theme
;;; 2. Google hyperlinks
;;; this code includes only one folder
(let ((base "/Users/Masi/.lisp"))
(add-to-list 'load-path base)
(dolist (f (directory-files base))
(let ((name (concat base "/" f)))
(when (and (file-directory-p name)
(not (equal f ".."))
(not (equal f ".")))
(add-to-list 'load-path name)))))
;// }}}*/
; customize hs-minor-mode// {{{*/
(add-hook 'c-mode-common-hook
(lambda()
(local-set-key (kbd "C-c <right>") 'hs-show-block)
(local-set-key (kbd "C-c <left>") 'hs-hide-block)
(local-set-key (kbd "C-c <up>") 'hs-hide-all)
(local-set-key (kbd "C-c <down>") 'hs-show-all)
(hs-minor-mode t)))
;// }}}*/
;; Folds// {{{*/
; to enable folding mode
(load "folding" 'nomessage 'noerror)
(folding-mode-add-find-file-hook)t
;;{{{ LaTeX mode stuff
(add-hook 'TeX-mode-hook
'(lambda ()
(LaTeX-math-mode)
(turn-on-reftex)))
;;// }}}*/
I get the following error
Loading encoded-kb...done
An error has occurred while loading `/Users/Masi/.emacs':
error: Too many arguments
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
In debug mode, it says
Debugger entered--Lisp error: (error "Too many arguments")
(defvar folding-package-url-location "Latest folding is available at http://cvs.xemacs.org/-xemacs-p (or (boundp 'xemacs-logo)\n $
eval-buffer(#<buffer *load*<2>> nil "/Users/Masi/.lisp/folding.el" nil t) ; Reading at buffer position 35362
load-with-code-conversion("/Users/Masi/.lisp/folding.el" "/Users/Masi/.lisp/folding.el" t t)
load("folding" nomessage noerror)
eval-buffer(#<buffer *load*> nil "/Users/Masi/.emacs" nil t) ; Reading at buffer position 2224
load-with-code-conversion("/Users/Masi/.emacs" "/Users/Masi/.emacs" t t)
load("~/.emacs" t t)
#[nil "^H\205\276^# \306=\203^Q^#\307^H\310Q\202A^# \311=\2033^#\312\307\313\314#\203#^#\315\202A^#\312\307\313\316#\203/^#\317\202A^#\315\202A^# \32$
command-line()
normal-top-level()
My ~/.lisp/folding.el
;;; folding.el --- A folding-editor-like minor mode.
;; This file is not part of Emacs
;; Copyright (C) 2000-2009
;; Jari Aalto
;; Copyright (C) 1995, 1996, 1997, 1998, 1999
;; Jari Aalto, Anders Lindgren.
;; Copyright (C) 1994
;; Jari Aalto
;; Copyright (C) 1992, 1993
;; Jamie Lokier, All rights reserved.
;;
;; Author: Jamie Lokier <jamie A T imbolc.ucc dt ie>
;; Jari Aalto <jari aalto A T cante dt net>
;; Anders Lindgren <andersl A T csd.uu dt se>
;; Maintainer: Jari Aalto <jari aalto A T cante dt net>
;; Created: 1992
;; Keywords: tools
;;
;; [Latest XEmacs CVS tree commit and revision]
;; VCS-Version: $Revision: 3.42 $
;; VCS-URL: http://savannah.nongnu.org/projects/emacs-tiny-tools/
;; VCS-Date: $Date: 2007/05/07 10:50:05 $
;;
;; [Latest devel: Savannah emacs-tiny-tools revision]
;; Version: git 56b3089
(defconst folding-version-time "2009.0220.1404"
"Last edit time in format YYYY.MMDD.HHMM.")
;;{{{ GPL
;; 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,
;; or (at your option) any later version.
;;
;; GNU Emacs 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 program. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;
;; Visit <http://www.gnu.org/copyleft/gpl.html> for more information
;;}}}
;;; Commentary:
;;{{{ Introduction
;; Preface
;;
;; This package provides a minor mode, compatible with all major
;; editing modes, for folding (hiding) parts of the edited text or
;; program.
;;
;; Folding mode handles a document as a tree, where each branch
;; is bounded by special markers `{{{' and `}}}'. A branch can be
;; placed inside another branch, creating a complete hierarchical
;; structure.
;;
;; Folding mode can CLOSE a fold, leaving only the initial `{{{'
;; and possibly a comment visible.
;;
;; It can also ENTER a fold, which means that only the current
;; fold will be visible, all text above `{{{' and below `}}}'
;; will be invisible.
;;
;; Please note, that the maintainers do not recommend to use only
;; folding for you your code layout and navigation. Folding.el is
;; on its best when it can "chunk" large sections of code inside
;; folds. The larger the chunks, the more the usability of
;; folding will increase. Folding.el is not meant to hide
;; individual functions: you may be better served by hideshow.el
;; or imenu.el (which can parse the function indexes)
;;}}}
;;{{{ Installation
;; Installation
;;
;; To install Folding mode, put this file (folding.el) on your
;; Emacs `load-path' (or extend the load path to include the
;; directory containing this file) and optionally byte compile it.
;;
;; The best way to install folding is the autoload installation,
;; so that folding is loaded into your emacs only when you turn on
;; `folding-mode'. This statement speeds up loading your .emacs
;;
;; (autoload 'folding-mode "folding" "Folding mode" t)
;; (autoload 'turn-off-folding-mode "folding" "Folding mode" t)
;; (autoload 'turn-on-folding-mode "folding" "Folding mode" t)
;;
;; But if you always use folding, then perhaps you want more
;; traditional installation. Here Folding mode starts
;; automatically when you load a folded file.
;;
;; ;; (setq folding-default-keys-function
;; ;; 'folding-bind-backward-compatible-keys)
;;
;; (if (load "folding" 'nomessage 'noerror)
;; (folding-mode-add-find-file-hook))
;;
;; Folding uses a keymap which conforms with the new Emacs
;; (started 19.29) style. The key bindings are prefixed with
;; "C-c#" instead of old "C-c". To use the old keyboard bindings,
;; uncomment the lines in the the above installation example
;;
;; The same folding marks can be used in `vim' editor command
;; "set fdm=marker".
;;
;; Uninstallation
;;
;; To remove folding, call `M-x' `folding-uninstall'.
;;
;; To read the manual
;;
;; At any point you can reach the manual with `M-x'
;; `finder-commentary' RET folding RET.
;;}}}
;;{{{ DOCUMENTATION
;; Compatibility
;;
;; Folding supports following Emacs flavors:
;;
;; Unix Emacs 19.28+ and Win32 Emacs 19.34+
;; Unix XEmacs 19.14+ and Win32 XEmacs 21.0+
;;
;; Compatibility not for old NT Emacs releases
;;
;; NOTE: folding version starting from 2.47 gets around this bug
;; by using adviced kill/yank functions. The advice functions are
;; only instantiated under problematic NT Emacs versions.
;;
;; Windows NT/9x 19.34 - 20.3.1 (i386-*-nt4.0) versions contained
;; a bug which affected using folding. At the time the bug was
;; reported by Trey Jackson <trey A T cs berkeley edu>
;;
;; If you kill folded area and yank it back, the ^M marks are
;; removed for some reason.
;;
;; Before kill
;; packages or modes
;;
;; Folding.el was designed tofor big files. Sometimes people misunderstand the
;; better job. Trying to wrap
;; individual functions insis not where folding is
;; it's best. Grouping several f logical fold-block
;; in the other is. So, to choose a our need,
;; here are some suggestions,:
;;
;; o Naation of imenu.el, speedbar.el and
;; hideshow.el
;; ng.el
;; o For text, `outline-mode' is more non-intrusive.
;; Look at Emacs NEWS file (`C-x' `n') and you can se: `M-x' `folding-mode'
;; `RET'. The mode line should cont When loading a document containing fold marks, Folding mode ised. For example when
;; loading my init file, only the follines
;; of comments) are visible:
;;
;; ;;{{{ Ge ;;{{{ Keyboard...
;; ;;{{{ Packages...
;; ;; ;;{{{ Minor modes...
;; ;;{{{ Debug...
;;
;t entering,
;; use `C-c # C-s', which produces this displa
;; ;;}}}
;;
;; To show everything, just as the fook like if
;; Folding mode hadn't been activated, give thT', normally bound to `C-c' `#'
;; `C-o'. To close all foevel, the
;; command `folding-whole-buffer' could be used.ouse support
;;
;; Folding mode v2.0 introduced mouse support. Folds can be shown
;; or hidden by simply clicking ondidn't click on a
;; fold mark.
;;
;; The menu
;;
;; placed in the "Tools" menu. Should no Tools menu exist
;; he menu will be placed in the menu bar.
;;
;; ISearch
;;
;; incremental search (C-s) facilities,
;; folds will be aut;;
;; Problems
;;
;; Uneven fold marks
;;
;; Oops, I ;;{{{
;; ;;}}}
;;
;; folding-whole-buffer d whole buffer
;;
;; If you call commands `folding-open-bufd
;; `folding-whole-buffer' and notice that there are open;; sections in the buffer, then you have mismatch of foldspen or closing fold mark.
;;
;; Folding and outline modes
;;
;ame as Outline mode, a major and
;; minor mode which is pahe Emacs distribution. The two
;; packages do, however, re other very much. The main
;; differences between the twore:
;;
;; o Folding mode uses explicit marks, `{{{' and `}}}', to
;; mark the beginning and the end of a branch.
;; Outline, on the other other hand, tries to use already
;; existing marks, like the `\section' string in a TeX
;; document.
;;
;; o Outline mode has no end marker which means that it is
;; impossible for text to follow a sub-branch.
;;
;; o Folding mode use the same markers for branches on all depths,
;; Outline mode requires that marks should be longer the
;; further, down in the tree you go, e.g `\chap', \section',
;; `\subsection', `\subsubsection'. This is needed to
;; distinguish the next mark at the current or higher levels
;; from a sub-branch, a problem caused by the lack of
;; end-markers.
;;
;; o Folding mode has mouse suppoyou can navigate through a
;; folded document by clicksion
;; of Outline mode has mouse support.)
;;
;; of Folding is capable of
;; automatically to open folthe the entire
;; document must be opened prior isearcutline mode is useful when the document being
;; edited coers are hard to find, except if you're happy with
;; one fn per fold.
;;
;; Future development ideas
;;
;; The planinning to rewrite the entire package.
;; Including replacithe program, written using
;; old Emacs technology (selectys or text-properties for
;; Emacs and extents for XEmacs.;;
;; It is not likely that any of this will come true coning
;; the time required to rewrite the core of the package. Since
;; the package, in it's current state, is much more powerful than
;; the original, it would be appropriate to write such package
;; from scratch instead of doing surgery on this one.
;;}}}
;;{{{ Customization
;; Customization: general
;;
;; The behavior of Folding mode is controlled mainly by a set of
;; Emacs Lisp variables. This section will discuss the most
;; useful ones, for more details please see the code. The
;; descriptions below assumes that you know a bit about how to
;; use simple Emacs Lisp and kt ~/.emacs, your
;; init file.
;;
;; Customization: hooks a
;; function doing the customization. The function is the see
;; the example section below.) The following hooks lding mode is activated.
;; o `<major mode>-folding-hookjor
;; mode set to <major mode>. (e.g. When editing C the hook `c-mode-folding-hook' is called.)
;; o `fol Called when folding mode is loaded into Emacs.
;;
;; C it is used by outline-minor-mode. It is not likely that fe try to use folding and outline at the same time.
;;
;; Ho. The
;; variable `folding-default-keys-function' specifiing line to your
;; init file:
;;
;; (setq folding-default-keys-function
;; 'folding-bind-backward-compatible-keys)
;;
;; To define keys similar to the keys used by Outline mode, use:
;;
;; (setq folding-defaut-keys-function
;; 'folding-bind-outline-compati-keys)
;;
;; Customization: adding new major modes
;;
;; To add fold marks for a new major mode, use the function
;; `folding-add-to-marks-list'. The command also replaces
;; existing marks. An example:
;;
;; (folding-add-to-marks-list
;; 'c-mode "/* {{{ " "/* }}} */" " */" t)
;;
; Customization: ISearch
;;
;; If you don't like the extension folding.el applies to isearch,
;; set the variable `folding-isearch-install' to nil before
;; loading this pacndard
;; ones, you can do like this:
;;
;; (setqs-function
;; '(folding-bind-backward-compatible- "Folding setup."
;;
;; (folding-install) ;; jus;; ............................................... markers ...
;; ;; sh/perl/awk code
;;
;; (defvar f-marks-alist nil)
;;
;; (let* ((ptr (assq 'text-mode folding-mode-marks-alist)))
;; (setcdr ptr (list "# {{{" "# }}}")))
;;
;; ;; .....................rrent-entry)
;; (define-key folding-mode-prefix-map 'folding-whole-buffer))
;;
;; Example:;; (defun my-folding-load-hook ()
;; "Foldi; Change marks for 'text-mode'
;; (let* ((ptr (assqing-mode-marks-alist)))
;; (setcdr ptr (list "# {{xample: choosing different fold marks for mode
;;
;; Suppoerent fold marks for the
;; major mode: e.g. to alternate (defun my-folding-text-mode-setup (&optional use-cu (interactive
;; (list (y-or-n-p "Us; (let* ((ptr (assq major-mode folding-mode-marks- (when (eq major-mode 'text-mode)
;; (setq begin default-begin end default-end)))
;; (setcdr ptr (list begin end))
;; f these 3 is to be folded at any
;; one time, using a simpomment types, e.g., "unfold
;; everything then fold on \x";;
;; \O ... \endO
;; \L ... \endL
;; "Folding vars setup."
;; (let ((ptr (assq 'te;; (define-key folding-mode-prefix-map "C"
;; 'my-folding-marks-change)))
;;
;; ctive "P")
;; (let ((ptr (assq major-mode folding-mome major-mode))
;; (setq input
;; read-string "Latex \\end(X) Marker (default O): "
;; (setq input (upcase input))
;; (turnncat "\\" input) (concat "\\end" input)))
;; (tu ;; End of example
;;
;; Bugs: Lazy-shot.el conflict in in the minibuffer and XEmacs freezes.
;;
;; The strange phat I have this bug only under Solaris
;; 2.5 sparc (binar.6 x86. (XEmacs 20.4, folding 2.35). I will try to access
;; ;; the XEmacs people I you can reproduce it.
;;}}}
;;{{{ Documentation
;; Old documentation
;;
;; The following s written by Jamie Lokier for the release
;; of Folding V1t is included here for no particular reason:
;;
;; Emacs 1 frames, then move in
;; and out of folds in the buffer. Tnerally in order to
;; avoid some Emacs display "features"ome of it is specific to
;; certain versions of Emacs. By ;;
;; More known bugs
;;
;; *** Needs folding-fold-regionk out what happens when you
;; exit a fold with the file dat sometime.
;;
;; Future features
;;
;; *** I will add a earlier versions does not count line-numbers in the right
;; ve.
;;
;; *** Fold titles should be optionally allowed on invisible text-properties (I hope they are intended to
;; sible; it isn't implemented like that yet), it
;; will be ed text without affecting the
;; text of the buffer. At thrns for line-feeds in the buffer. This isn't such
;; a gooeven more text-properties, it may be possible to track
;; and out of folds, and have Folding mode
;; automatically e necessary to maintain a
;; sensible display. Because the dified (if
;; overlays are used to hide text), this is quiorward-char', `folding-goto-line' or
;; `folding-next-erromight make it possible to
;; avoid using narrowing. This m3cff7]
;; - Minor documentaton fixes.
;; - Add new `python-mode [jari 3.36-3.37 2006.1118]
;; - Jeremy Hankins <nowan An org> sent a patch, which
;; adds variable `folding-narrow-batch affects
;; mostly `folding-shift-in'. This makes it possader to the beginning for canonnical location.
;; Updated maid from bibtex-mode.
;; Changed bib-mode '#comment' => '%'. Clian
;; Bug#282388
;;
;; Sep 10 2004 21.3 [jari0]
;; - (folding-fold-region): caused to indent bottom fold
;; -mode. Disabled
;; running `indent-according-to-mode' while i; Bug reported by Uwe Brauer; oub A T mat dot ucm dot es
;; -whole buffer.
;; - Changed version scheme to date based YYYY.MMed unnecessary 'all rights reserved'.
;; - (folding-check-foldeter, which
;; - protected all email addresses by removing AT-si2.111-2.115]
;; - Merged in changes made by 2003-11-12 Adrian ; using different expansion macros for XEmacs and Emacs.
;; rg/xemacs-beta/199810/msg00039.html
;; - (folding-forward-char- 2.112 Renamed.
;; Was `folding-forward-char'.
;; (folding-ar-1): 2.112 Renamed.
;; Was `folding-backward-char'.
;; (fion with '_p' interactive spec.
;; (folding-backward-char-macolding-interactive-spec-p): 2.112 New.
;;
[...]

There's at least one error in the code in your .emacs, here:
; to enable folding mode
(load "folding" 'nomessage 'noerror)
(folding-mode-add-find-file-hook)t
That t is a syntax error as it stands. Might just be a type frpom cut and paste though.
On the error, Trey'd right, and in fact I think I know what the error probably is: somehow the trailing quote mark in the string
"Latest folding is available at http://cvs.xemacs.org/-xemacs-p
has gone missing. From the two of these issues, I suspect your source is corrupt.

It looks like your folding file /Users/Masi/.lisp/folding.el has a problem, we'd need to see the contents of that to determine the error. The reason I say so is that the stack trace goes through a call to load-with-code-conversion - which shows the folding.el file being loaded.
If you take a look at the latest version, found here (version 3.42), the line that begins
(defvar folding-package-url...
is properly formed. However, the stack trace in yours looks like there is some lisp code that somehow made it into the string. Namely the:
(or (boundp 'xemacs-logo)
Try downloading a fresh copy.

Related

Emacs exclude a keyword from indentation (Verilog)

I have an issue with using the following emacs indentation option
setq verilog-cexp-indent
I want to set it to 4 to apply for 1 line if-else, for, case .. etc
But when I do, it indents the module keyword.
Can I exclude the "module keyword" from this or is there a better way to do it ?
You should look at the instructions to Verilog mode. To do that, do M-x find-library<RET>verilog-mode<RET>. In there you'll see (amongst other information):
;; ;; User customization for Verilog mode
;; (setq verilog-indent-level 3
;; verilog-indent-level-module 3
;; verilog-indent-level-declaration 3
;; verilog-indent-level-behavioral 3
;; verilog-indent-level-directive 1
;; verilog-case-indent 2
;; verilog-auto-newline t
;; verilog-auto-indent-on-newline t
;; verilog-tab-always-indent t
;; verilog-auto-endcomments t
;; verilog-minimum-comment-distance 40
;; verilog-indent-begin-after-if t
;; verilog-auto-lineup 'declarations
;; verilog-linter "my_lint_shell_command"
;; )

lexical-binding not being enabled when evaluating .emacs

Here are some excerpts from my .emacs:
(setq lexical-binding t)
;; .emacs
(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.
'(diff-switches "-u")
'(tab-always-indent (quote complete)))
;...
(require 'dired)
;...
(dotimes (i 12) (define-key dired-mode-map (kbd (concat "<f" (number-to-string (1+ i)) ">"))
(lambda ()
(interactive)
(goto-char (point-min))
(forward-line (+ 4 i)))))
This should bind keys f1 to f12 in dired-mode to commands that jump to particular files in the list of files (ignoring . and ..). However, initially, after starting emacs, these keys don't work - I get an error message forward-line: Symbol's value as variable is void: i. However, when I go to the top line of my .emacs and press C-x C-e to evaluate that line, and then go to the last line quoted above and press C-x C-e to evaluate that dotimes expression, those function keys start working!
Why is that?
By the way, it also doesn't work if I evaluate the whole buffer.
It turns out that it is necessary to replace
(setq lexical-binding t)
with
;; -*- lexical-binding: t -*-
The manual hints suggestively at this, but does not actually say so outright.

emacs indentation inconsistent in nesed loops

I am working on C code.
I have a problem same as that in this question.
The solution there is to use spaces instead of tabs. But I'm trying/I'd prefer to use Smart Tabs Mode.
I've tried enabling and disabling both "c-tab-always-indent" and "indent-tabs-mode" (in cc-mode-hook).
The problem I see is that in some parts of the code a nested loop generates two Tabs, as expected(?). But in some cases, it generates only one tab and four spaces, while in other cases it generates only one tab, something like below:
function_name
open brace here
...code indented by 4 spaces (though I want a tab)>
open_brace
_tab_ code under condition
_4spc_ close_brace
some more 4 space aligned code
_tab_ open_brace
_tab+4spc_ code under some block
_tab_ close_brace
some more 4 space aligned code
_tab_ open_brace
_2 tabs_ code aligned as I prefer with two tabs
_tab_ close_brace
Can someone help me with getting the last style in the whole code?
My .emacs file is here (I use a few packages, like cscope and hide-show, but I don't think that should cause problems):
(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.
'(ansi-color-faces-vector [default default default italic underline success warning error])
'(ansi-color-names-vector ["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"])
'(c-basic-offset 4)
'(c-cleanup-list (quote (scope-operator space-before-funcall compact-empty-funcall)))
'(c-default-style (quote ((c-mode . "linux") (c++-mode . "linux") (java-mode . "java") (awk-mode . "awk") (other . "gnu"))))
'(c-hanging-braces-alist (quote set-from-style))
; '(c-tab-always-indent t)
'(custom-enabled-themes (quote (tango-dark)))
'(save-place t nil (saveplace))
'(show-paren-mode t))
(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.
)
(setq savehist-additional-variables ;; also save...
'(search-ring regexp-search-ring) ;; ... my search entries
savehist-file "~/.emacs.d/savehist") ;; keep my home clean
(defalias 'yes-or-no-p 'y-or-n-p) ; to answer y or n instead of yes or no :-P ...I'm to lazy
(setq search-highlight t ;; highlight when searching...
query-replace-highlight 1) ;; ...and replacing
(add-to-list 'load-path "~/.emacs.d/packages/")
(add-to-list 'load-path "~/share/emacs/site-lisp")
;;;add packages
;;(require 'doxymacs)
;;; turn ons
(ido-mode)
(savehist-mode 1)
(setq show-paren-mode 1)
(global-linum-mode 1)
(setq column-number-mode 1)
;;cc-mode changes
(require 'smart-tabs-mode)
(require 'xcscope)
(cscope-setup)
(autoload 'smart-tabs-mode "smart-tabs-mode"
"Intelligently indent with tabs, align with spaces!")
(autoload 'smart-tabs-mode-enable "smart-tabs-mode")
(autoload 'smart-tabs-advice "smart-tabs-mode")
(autoload 'smart-tabs-insinuate "smart-tabs-mode")
(defun my-c-mode-common-hook ()
(setq require-trailing-newline 1) ;; Always add a final newline
(which-function-mode 1)
(subword-mode 1)
(hs-minor-mode 1)
(setq show-paren-style 'parenthesis)
; (setq indent-tabs-mode t)
(smart-tabs-mode 1)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

I cannot get structure members in auto-completion or tooltips

I want autocomplete or company to work with C code and I need structure context level autocomplete i.e if I have a struct:
typefdef struct HOST_ {
IP4_ADDRESS ip4;
IP6_ADDRESS ip6;
MAC_ADDRESS mac;
} HOST;
... and then I have code:
HOST host;
host->
Then if I hit tab then I should get a drop down menu giving me all the (and only the) three options.
This is what I did:
(defun my-tab-del-commands(key-map)
"This function sets the <tab> and <backspace> keymaps according to the special commands
that I have set. This needs to be set per mode keymap where it is needed. We cannot
use the global keymap because that would override command completion in minibuffer"
;; Set TAB in major-mode keymap to "tab-to-tab" stop
;; Use tab2tab stop and not just add +4 spaces (tab stop defined by tag-stop-list)
(define-key key-map (kbd "<tab>") 'tab-to-tab-stop)
;; Define Key for <backtab>
(define-key key-map (kbd "<S-tab>") 'backward-move-to-tab-stop)
(define-key key-map (kbd "<backtab>") 'backward-move-to-tab-stop)
;; Define C-tab as my-indent-system
(define-key key-map (kbd "<C-tab>") 'my-indent-system)
;; Also provide a duplicate "\C-ci" in case C-TAB is overridden by any minor mode
(define-key emacs-lisp-mode-map "\C-ci" 'my-indent-system)
;; Shift backspace moves by one tab stop till no more whitespace
(define-key key-map (kbd "<S-backspace>") 'backspace-whitespace-to-tab-stop)
;; Alt backspace is c-hungry-delete-backwards
(define-key key-map (kbd "<M-backspace>") 'c-hungry-delete-backwards)
)
;; Simple Backend of semantic with ede as project manager
;; Lets try semantic (CDET) backend for now only.
;; Later learn clang or rtags or other big stuff to handle the whole project
(defun backend:semantic-ede ()
"Setup for semantic-mode with ede as project management.
Simple stuff for starters"
(semantic-mode 1)
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(setq-mode-local c-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(semantic-add-system-include my-lp-build-path)
(semanticdb-enable-gnu-global-databases 'c-mode t)
(semanticdb-enable-gnu-global-databases 'c++-mode t)
(require 'ede)
(global-ede-mode)
(let ((makefile (format "%s/Makefile" my-mp-source-path)))
(when (file-exists-p makefile)
(ede-cpp-root-project "openflow" :file makefile)))
)
;; There are two "schools of thought" of intelligent autocomplete
;; (a) auto-complete package and (b) company package.
;; This is auto-complete
(defun completion:auto-complete ()
"Setup auto-complete with triggers. We still need to hook with C mode"
;; Then autocomplete
(require 'auto-complete)
(require 'auto-complete-config)
(global-auto-complete-mode t)
;; auto complete mod
;; should be loaded after yasnippet so that they can work together
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
;; set the trigger key so that it can work together with yasnippet on tab key,
;; if the word exists in yasnippet, pressing tab will cause yasnippet to
;; activate, otherwise, auto-complete will
(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")
(global-auto-complete-mode t)
)
(defun my-smart-c-auto-complete()
;; Now tie up autocomplete with semantic
;; Later hook it up to c-mode-hook via c-mode-config func
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-words-in-same-mode-buffers)
(add-to-list 'ac-sources 'ac-source-dictionary)
(add-to-list 'ac-sources 'ac-source-abbrev)
(add-to-list 'ac-sources 'ac-source-semantic)
(add-to-list 'ac-sources 'ac-source-c-headers)
)
;; This is company
(defun completion:company ()
"Setup comany mode"
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
)
(defun tab-side-story ()
(interactive)
;; First load and init Yasnippet - This sets the TAB first to Ysnippet
;; This will work on LISP & SHELL SCRIPTS also
;; (require 'yasnippet)
;; (yas-global-mode 1)
;; Second, use whatever completion mechanism you wanna use auto-complete or company
;; This will work on LISP also!
;;(completion:auto-complete)
(completion:company)
;; Then this function sets tab command
(my-tab-del-commands c-mode-base-map)
)
;; Completion mechanism needs a backend
(backend:semantic-ede)
(tab-side-story)
;; define My Great C style with linux as the parent style (choose google if you wish)
(c-add-style "my-great-c-style"
'("linux" ; use linux as parent style
(indent-tabs-mode . nil) ; tabs are spaces
(c-syntactic-indentation . t) ; auto-syntax
(c-syntactic-indentation-in-macros . t) ; ditto for macros
(c-tab-always-indent . nil) ; Otherwise our complex TAB will not work!
(tab-width . 4) ; if there is a <tab> expand to 4 spaces
(backward-delete-function . nil) ; DO NOT expand tabs when deleting
(c-continued-statement-offset . 4))) ;continued statement offset 4
(defun my-c-mode-config ()
(c-set-style "my-great-c-style")
(when (= emacs-major-version 23)
(gtags-mode 1))
(when (= emacs-major-version 24)
(tab-side-story)
;; (my-smart-c-auto-complete)
(ggtags-mode 1)
(setq ggtags-update-on-save nil))
(electric-indent-mode)
(setq c-basic-offset 4)
(setq c-tab-always-indent nil))
;; Needs to be hooked - do it here instead of common area
(add-hook 'c-mode-hook 'my-c-mode-config)
Sorry for the very long code but most of them are my comments and notes jotted down so far less "code" than it seems. In this I have set it for company mode though I have auto-complete.
Both are not working! Something is clashing with something.

Emacs: Tab completion of file name appends an extra i:\cygwin

I am facing some strange behavior with file-name completion in emacs. C-x C-f to find file opens up the minibuffer with i:/cygwin/home/rrajagop/StockScreener/working_copy/master_repo/stock_screener/. Hitting a TAB makes it i:/cygwini:/cygwin/home/rrajagop/StockScreener/working_copy/master_repo/stock_screener/. A couple of interesting things I've noticed:
When the minibuffer opens up, i:/cygwin is greyed out and the path seems to start from /home. A C-a (go to begining of line) takes me to /home and not to i:/cygwin. So it looks like something in emacs is parsing the path to start from /home and not from i:/cygwin.
I checked that TAB runs minibuffer-complete from minibuffer.el (by doing a describe-key for TAB), so it looks like minibuffer-complete is doing some translation for cygwin and appending the extra i:/cygwin.
How would I go about figuring this out/fixing it?
EDIT: Extra Information
I tried opening up emacs with -Q and this problem doesn't happen. So this is something I'm loading in my .emacs. This is what I have in my .emacs
(require 'cl)
; Needed to see how fast Emacs loads. Loading time is printed at the
; and of the execution of .emacs file.
(defvar *emacs-load-start* (current-time))
; I really like this font. I also tried Monaco which you can
; see on lot of Railscasts but I couldn't find the one which
; supports Serbian Cyrillic and Latin letters.
(set-default-font "-outline-Courier New-normal-r-normal-normal-19-142-96-96-c-*-iso8859-1")
;; Don't show that splash screen
(setq inhibit-startup-message t)
; This should allegedly speed up Emacs starting by preventing
; some requests from the window manager back to the Emacs. Frankly
; speaking I didn't notice some speed up but I still keep it:(
(modify-frame-parameters nil '((wait-for-wm . nil)))
;Allows syntax highlighting to work, among other things
(global-font-lock-mode 1)
; Sets initial window position
(set-frame-position (selected-frame) 0 0)
; Sets initial window size to 85 columns and 47 rows
(set-frame-size (selected-frame) 88 32)
; Makes last line ends in carriage return
(setq requre-final-newline t)
; Sets Ctrl-x / key combination for easy commenting
; out of selected lines.
(global-set-key "\C-x/" 'comment-or-uncomment-region)
; Allow resizing of the mini-buffer when necessary
(setq resize-minibuffer-mode t)
; Auto magically read compressed files
(auto-compression-mode 1)
; Set standard indent to 2 rather then 4
(setq standard-indent 2)
; This tells Emacs to create backup files.
(setq make-backup-files t)
; And this will enable versioning with default values.
(setq version-control t)
; Remove annoying message about deleting excess backup of .recentf
; which is list of recent files used
(setq delete-old-versions t)
; Finally do not spread backups all over the disk.
; Just save all backup files in this directory.
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
;; Directory to put various el files.
(add-to-list 'load-path "~/.emacs.d/includes")
(require 'ascii-table)
;; Loading collection of generic modes for different languages
(require 'generic-x)
;; Recent files
(require 'recentf)
(recentf-mode 1)
;; Loads ruby mode when a ruby file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".rhtml$" . html-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".html.erb$" . html-mode) auto-mode-alist))
;; Turn on ruby electric (auto completion of parenthesis, etc.)
(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace) )))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar "IMENU")
(define-key ruby-mode-map "\C-m" 'newline-and-indent)
(require 'ruby-electric)
(ruby-electric-mode t) ))
;; Ruby debugging.
(add-to-list 'load-path "~/.emacs.d/plugins/rdebug")
(autoload 'rdebug "rdebug" "Ruby debugging support." t)
(global-set-key [f9] 'gud-step)
(global-set-key [f10] 'gud-next)
(global-set-key [f11] 'gud-cont)
(global-set-key "\C-c\C-d" 'rdebug)
;; set compile command based on current major mode
(autoload 'mode-compile "mode-compile"
"Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Command to kill a compilation launched by `mode-compile'" t)
(global-set-key "\C-ck" 'mode-compile-kill)
;; yasnippet - adding code snippet insertion
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet/snippets")
;; Use CYGWIN bash
(require 'setup-cygwin)
;; Subversion integration via psvn - not gonna use svn anymore
;; (require 'psvn)
;; add some elisp tutorials to the info directory
(let ((info-root (concat usb-drive-letter "cygwin/usr/local/bin/emacs/info/")))
(setq Info-directory-list (list info-root
(concat info-root "elisp-tutorial-2.04/")
(concat info-root "emacs-lisp-intro-2.14")) )
)
;; Load time for .emacs - this should be the last line in .emacs for accurate load time
(message "ido and org-install took: %ds"
(destructuring-bind (hi lo ms) (current-time)
(- (+ hi lo) (+ (first *emacs-load-start*) (second *emacs-load-start*)) )))
I think my answer to your previous question on finding the package loading tramp will help you out here.
you can control tramp by changing the variable tramp-mode.
Side note, you would probably find it useful to use customize to customize emacs.
I did a customize-apropos with tramp and it found the tramp group. Clicking there showed all the ways to configure tramp, including turning it off.
File-name-shadow-mode greys out the c: in the file name..... so when cygwin-mount-substitute-longest-mount-name runs it does no see the c: and adds another
M-x find-file
c:/home/
> a
c:/home/a ; but the c: is greyed
> TAB
c:c:/home/anything