When using Emacs 24.3.1 on Windows 7, I found that cygwin-mount.el would not work (it gave a bogus error of being unable to locate mount.exe) or using version control (cvs) within Emacs would fail with “Permission Denied”. Turns out the problem was Windows UAC (User Access Control). By changing the properties on runemacs.exe to “Run as administrator”, I was able to fix this issue.
To ensure that Windows 7 Emacs uses the Cygwin Bash shell when executing the compile command (M-x compile) and to ensure that Bash reads the .bashrc, do the following:
(setq shell-file-name "bash") (setq shell-command-switch "-ic")
The title says it all. This is some documentation to track how to get colors right when using PuTTY from Windows to SSH into a Linux server and then use Emacs in text-mode and edit php or other programming language files in syntax highlighted color.
In PuTTY, first make the following change (away from the default) — On the left-hand side configuration Category tree, select the Data sub-node from the Connection node. In there change, the “Terminal-type string” to “xterm-256color”
Once you connect and login to the Linux server, do “echo $TERM” and you should see “xterm-256color” as a result. This allows the terminal emulation to support an xterm-type terminal with 256 colors. Once logged in, if you run “tput colors“, you should see “256” as the result of running this command.
Then run Emacs — Emacs will run in text-mode. Within Emacs, run the command ‘list-colors-display‘. This should display 256 colors.
After this, you need to load up the appropriate major mode for the language you are going to be working on to get proper syntax coloring for that language (if you don’t use a suitable mode, you might get some syntax color, but not all the syntax coloring that will be supported in a full-fledged mode that is designed to support the language of your choice).
sed -i ‘3d’ filename.ext
The above deletes the 3rd line in file filename.ext. The -i option replaces the filename.ext with the modified file (i.e. the change is made in place). Omit this option if that is not what you want.
This requires use of standard C library support for the clock_gettime() function. This returns time as a data-structure (struct timespec) that includes the current time in seconds and nano-seconds. Call this one time before the section of code to evaluate and once after and then take a difference of the end time versus the start time to figure out the time taken in the section of code.
struc timespec timespec_diff(struct timespec end, struct timespec start)
struct timespec start, end, diff;
for (i = 0; i < 100000; i++)
x = i * 45;
diff = timespec_diff(end, start);
printf(“Section of code took %u seconds %d nano-seconds\n”, diff.tv_sec, diff.tv_nsec);
This requires use of standard C library support for the clock_gettime() function. This function returns clock time as a data-structure (struct timespec) that includes the the clock time in seconds and nano-seconds.
Call this function one time before the section of code to evaluate and once after and then take a difference of the end time versus the start time to figure out the time taken in the section of code.
…isn’t tested, then did you really need to write that code?
Note To Self: In any system where you have multiple processes or tasks handling processing of various events and you provide a mechanism in one process or task for other modules to register a callback, you should also allow for a life-time parameter in the registration that is returned whenever the callback is called. This is so that if callbacks are processed asynchronously by queue-ing messages by the process registering callbacks, there can be stale messages in queue during which time the registration could be deleted and new registrations can happen. So there has to be a mechanism for the callback owner to be able to distinguish the life-time instance of the registration against which the callback was originally made.
Note to self: If modifying a structure to include a new field, search for all uses of the data structure and check that this new field is initialized everywhere and not just in the place you wanted to use the new field!
If you are trying to use the C programming language’s sizeof operator in a C pre-processor macro and find that you are unable to use it as expected and you see compiler errors (actually C pre-processor (CPP) errors), you are really seeing expected behavior. The sizeof operator works only during compile time and the sizes of structures are only known at compile time and it is not an operator supported by the C pre-processor.