Working on my first sbcl project in slime mode, I have trouble with setting up emacs properly for navigating within my code: Often, I would like to jump to the function definition (to any custom function within my source code) of a function. Therefore find-function seems to be a good starting point. Unfortunately, find-function never finds any of my functions: [No match]! My source code is located in a simple file like geometry.lisp with function definitions like:
(defun get-right-normal(vector)
"Computes right-normal of given vector"
(make-2d-vector :x (* -1 (2d-vector-y vector)) :y (2d-vector-x vector)))
I added the path of the source file to the 'load-path variable:
(add-to-list 'load-path "/path/to/src")
The description of find-function says
The library where FUNCTION is defined is searched for in
`find-function-source-path', if non-nil, otherwise in `load-path'.
But trying to set `find-function-source-path by
(add-to-list 'find-function-source-path "/path/to/src")
returns
Symbol's value as variable is void: find-function-source-path
How can I set the value of this variable? What am I doing wrong?
You must define things before you can ask for their values. The error message tells you that variable find-functions-source-path is not defined. Why? Because you have not loaded the library that defines it. You need to load library find-func.el[c]: (require 'find-func).
Related
I use a custom version of org-mode called lawlist-org-mode -- every function and variable have the prefix lawlist- and the modified version has many custom features that are not available in the stock version. Occasionally, I like to use the stock org-mode version -- however, that requires manually modifying the auto-mode-alist and then restarting Emacs. This is necessary due to the function and variable org-agenda-files and the check that org-mode performs to verify that the proper major-mode is present. Is there an efficient method to modify this programmatically depending upon the function being called?
The stock org-mode needs this entry:
(add-to-list 'auto-mode-alist '("\\.todo\\'" . org-mode))
The custom version called lawlist-org-mode needs this entry:
(add-to-list 'auto-mode-alist '("\\.todo\\'" . lawlist-org-mode))
Examples:
If I call M-x org-agenda, the .todo files needs to be in org-mode.
If I call M-x lawlist-org-agenda, the .todo file needs to be in lawlist-org-mode.
Some Ideas: The org-agenda-files are generally accessed by org-agenda functions using the following lines of code -- (org-agenda-files nil 'ifmode) . . . (while (setq file (pop files)). Perhaps modifying the function org-agenda-files would be an option?
The FUNCTION part of an auto-mode-alist entry (i.e., the cdr) is just a function. It is called, in principle to set up a major mode. But it can do anything.
In particular, you could have an entry ("\\.todo\\'" . foo), where function foo conditionally calls either lawlist-org-mode or org-mode.
E.g, it could use lawlist-org-mode when the moon is full and org-mode otherwise. Or it could test a global variable, which you set when you want to switch from one to the other. And so on.
At least that's my reading of the auto-mode-alist doc string. I've never tried it.
In emacs, org-mode has been enabled and have opened some *.org files. Now in the init.el file i am trying to enable the outline-minor-mode in order to fold the lines starting with ";" . When i try to evaluate the (outline-minor-mode) command i get the message "Symbol's function definition is void: th-outline-minor-mode-init"
Seems like the org-mode sets up the outline-minor-mode-hook
outline-minor-mode-hook's value is (th-outline-minor-mode-init)
This variable may be risky if used as a file-local variable.
How to setup the outline-minor-mode for init.el file so that the ";" is treated as heading.
Note:- When emacs is launched with --no-init-file option, outline-minor-mode works for init.el file
Doesn't org-mode use an org- prefix pretty consistently?
On that assumption, th-outline-minor-mode-init doesn't look like an org-mode function to me, so something else is probably at fault, and you'll need to find out what.
Obviously you can't find-function if it's void, so I'd just M-x rgrep your config for th-outline-minor-mode-init (or most likely searching for (add-hook 'outline-minor-mode-hook 'th-outline-minor-mode-init will find the culprit directly).
That issue aside, I happen to use outline-minor-mode in my init file (with headers being lines beginning with ;;;;, and auto-folding the ones beginning with ;;;; *), using the following Local Variables block at the end of the file:
;;; Local Variables:
;;; outline-regexp: ";;;; "
;;; eval:(progn (outline-minor-mode 1) (while (re-search-forward "^;;;; \\* " nil t) (outline-toggle-children)))
;;; End:
I keep a lot of documentation in the file, and with <backtab> bound to outline-toggle-children I find this a pretty convenient way to access it.
I want to use the pomodoro technique in org-mode as explained in
http://orgmode.org/worg/org-gtd-etc.html
I have added the following lines in .emacs file
(add-to-list 'org-modules 'org-timer)
(setq org-timer-default-timer 25)
(add-hook 'org-clock-in-hook '(lambda ()
(if (not org-timer-current-timer)
(org-timer-set-timer '(16)))))
When starting the emacs the following warning is displayed in the Warnings buffer.
Symbol's value as variable is void: org-modules
I am using org-mode version - 7.7.291.g37db which is cloned from git://orgmode.org/org-mode.git
How to get rid of the error.
org-modules is defined in org.el. If you want to add an element to the list, you need to wait until the variable is defined (with a default list). One way to do that is delay the addition until immediately after org.el is loaded:
(defun my-after-load-org ()
(add-to-list 'org-modules 'org-timer))
(eval-after-load "org" '(my-after-load-org))
Note that add-hook can cope with a variable that isn't defined yet, but add-to-list can't. You could write (setq org-modules '(org-timer)), but that would overwrite the default module list instead of adding to it.
I want to load my file named "my-c-setup.el" when the c-mode is loading. So, I'm using the function "autoload".
With my python setup, it works well :
lang.el
(autoload 'python-mode "my-python-setup" "" t)
my-python-setup.el
(require 'python)
; ...
I'm trying to do the same with the c-mode, but i does not work :
lang.el
(autoload 'c-mode "my-c-setup" "" t)
my-c-setup.el
(setq c-basic-offset 4)
; ...
When I try to open a file in c-mode (test.c for example), I have the following error :
File mode specification error: (error "Autoloading failed to define function c-mode")
Autoload is not what you're looking for. What it does is simply load some code the first time it is needed, which is a handy way to extend Emacs' functionality while still keeping the start-up time low.
To solve your problem, we gotta think about what you really want to do: do you simply want some of your code to be loaded at some point, or do you want buffer-local customizations for ever buffer that is in c-mode?
If you simply want Emacs to load your code at start-up, either put your code directly into your .emacs file or use load-file or require instead of autoload:
load-file simply takes a file name, loads the lisp code in that file and evaluates it. So if your code is in a file named "/path/to/my-c-setup.el", you could put the following line in your .emacs, and the code will be loaded on every start-up:
(load-file "/path/to/my-c-setup.el")
Perhaps you don't want to give the absolute path name for every file you load. In that case, you could use the function load-library instead which is similar to load-file but tries to find the given filename in any of the directories stored in the variable load-path:
(add-to-list 'load-path "/path/to")
(load-library "my-c-setup.el")
The advantage is that you have to do the add-to-list part only once, and all subsequent calls to load-library will be able to find code in that directory.
An alternative way is the provide/require mechanism: you can make your .el-file "provide" some feature by putting a (provide 'feature) call in it, e.g.
(provide 'my-c-mode-customizations)
Then put an according (require 'feature) in your .emacs file, and your code will be loaded as well:
(require 'my-c-mode-customizations)
However, if you want your code only be loaded when c-mode is activated on a buffer, the way to achieve that is through Emacs' Hook mechanism:
A hook is a variable where you can
store a function or functions to be
called on a particular occasion by an
existing program.
Most major modes provide a customizable hook variable to which you can add functions that will be called whenever the major mode is invoked. For instance, c-mode provides c-mode-hook. In order for your own customizations to be called whenever c-mode is turned on for a buffer, put them in a function, say, my-c-mode-customizations and add the following line to your .emacs file:
(add-hook 'c-mode-hook 'my-c-mode-customizations)
Of course, you still need autoload for Emacs to actually find the definition of that function.
Lisp's autoload does not call a function when a file is loaded but tells lisp that the function is available and that the given file provides it. Whenever someone calls the (not yet defined) function, the file is loaded.
I think that c-mode is already defined and thus fails to re-register.
Autoload doesn't do what you think it does.
http://www.gnu.org/software/emacs/elisp/html_node/Autoload.html
What you probably want are mode-hooks or eval-after-load.
See eval-after-load vs. mode hook for the difference between the two.
This is rather queer. I can't set any value to a variable if it is named 's' in an interactive session:
(setq s 'foo)
=> foo
s
=> nil
Why?
Update 1:
Here is the output from describe-variable on s:
s is void as a variable.
Documentation:
Not documented as a variable.
Why is it that s is kept void in emacs lisp as a global variable?
Update 2:
Turned out, it doesn't happen on a vanilla emacs (meaning one of the modules I load in .emacs or some code in .emacs is causing this).
So the question now is:
What would the original source look like when describe-variable yields "<var> is void as a variable"?
I tried it with setq, defconst, defvar, and defcustom, but none of those produced the message I'm showing.
Update 3:
The message shown above is produced when the variable is literally not bound (though it can be fbound).
(describe-variable 'non-existent)
=> "non-existent is void as a variable.
Documentation:
Not documented as a variable."
So latest question is: Is there any way to prevent a certain variable name
from being bound?
An answer to your revised question:
(defvar s)
The only thing is that this won't let you use describe-variable on it interactively.
(You could then do something like (setplist 's '(variable-documentation "Meh")) to set a description for it without going through defvar.
Just bisect your init file (~/.emacs) recursively until you find the sexp that causes the problem. If it is a sexp that loads another library then either don't use that library or fix it by first finding out what its problem is, the same way: bisect the code in that library recursively, etc.
This is a binary search, and it is very quick. You can quickly comment out half, then 3/4, 7/8, etc. of your file, using M-x comment-region (I bind it to C-x ;). with a prefix arg, comment-region uncomments.
With Emacs 23.1, running the following code makes C-h v s RET show “s is void as a variable.”, but I can't reproduce the inconsistency between setq and retrieving the value of the variable (which I agree is weird).
(setq s t)
(make-local-variable 's)
(makunbound 's)
I suspect an Emacs 24-specific feature or bug.