texts: How to override a value inside a function temporarily?

texts:
There is this function in tide:
;; Defined in ~/.emacs.d/.local/straight/repos/tide/tide.el
(defun tide-rename-file ()
  "Rename current file and all it's references in other files."
  (interactive)
  (let* ((name (buffer-name))
         (old (tide-buffer-file-name))
         (basename (file-name-nondirectory old)))
    (unless (and old (file-exists-p old))
      (error "Buffer '%s' is not visiting a file." name))
    (let ((new (read-file-name "New name: " (file-name-directory old) basename nil basename)))
      (when (get-file-buffer new)
        (error "A buffer named '%s' already exists." new))
      (when (file-exists-p new)
        (error "A file named '%s' already exists." new))
      (let* ((old (expand-file-name old))
             (new (expand-file-name new))
             (response (tide-command:getEditsForFileRename old new)))
        (tide-on-response-success response (:min-version "2.9")
          (tide-do-rename-file old new (plist-get response :body))
          (message "Renamed '%s' to '%s'." name (file-name-nondirectory new)))))))

It works well, but it works when called inside a buffer and with manual input of parameters.
I want to turn it into a function that I can call from elisp with the parameters sent through code instead of using the minibuffer through read-file-name. Ideally something like
(defun tide-rename-file-MODIFIED (new old) .... )

I would like this to be a function with a new name e.g. tide-rename-file-MODIFIED, so that I can still call tide-rename-file as usual, from inside a buffer, with manual user input.
Perhaps I am better off writing my own function instead of trying to modify the existing function? I don't know.
Related Qs

Monkey patching a function
How to add a locally override the message function?
Override a function locally, but allow calls to the original function


texts: How can I view the hierarchy of TODO keywords in org agenda mode?

texts:
I have a variety of (facile) tasks in some kind of hierarchy.

* TODO Make a pizza
** TODO Get cheese
*** TODO Buy a cow
** TODO Get tomatoes
*** TODO Grow tomatoes
**** TODO Buy tomatoes
** TODO Buy oven
*** TODO Win Lottery
**** TODO Buy Lottery ticket

If I view these in with the org agenda, they're displayed in a flat fashion:

  .TODO:    TODO Make a pizza
  .TODO:    TODO Get cheese
  .TODO:    TODO Buy a cow
  .TODO:    TODO Get tomatoes
  .TODO:    TODO Grow tomatoes
  .TODO:    TODO Buy tomatoes
  .TODO:    TODO Buy oven
  .TODO:    TODO Win Lottery
  .TODO:    TODO Buy Lottery ticket

I'd like to view these tasks in an indented fashion, so they reflect the dependencies between the tasks. Is this possible / a good idea or am I just using the agenda incorrectly?


texts:
How to use auto-complete with use-package and have auto-complete loaded later?

Following config is working, but how to get rid of the defer 2?

(use-package auto-complete-config
    :defer 2
    :bind (:map ac-mode-map
                ("M-<tab>" . auto-complete))
    :init
    (setq ac-auto-start nil
          ac-quick-help-delay 0.5)
    :config
    (global-auto-complete-mode t))

I tried global-auto-complete-mode and auto-complete mapped to global key map key M-TAB but both are not working.


texts: Compiling gccemacs (Emacs 28) from source. To bootstrap or not to bootstrap?

texts:
With the following build script on Big Sur + homebrew, I get horribly long compile times when using make bootstrap as opposed to simply make on gccemacs.
I've read the Makefile in the src directory - the explanation for bootstrap is pretty stoic.
# make bootstrap
#      Removes all the compiled files to force a new bootstrap from a
#      clean slate, and then build in the normal way.

However, I see some articles on the interwebs (by people much more skilled than myself) that use make bootstrap in their Emacs builds.
Are there any gains (error-checking, performance, ???) by make-ing Emacs with make bootstrap (as opposed to just make)?  Curious if I'm missing any 'features' by omitting bootstrap from my build script.
export CC=/usr/bin/clang
# exporting CXX (NOT CC) to gcc-10 results in huge compile performance gains.
export CXX=/usr/local/bin/gcc-10

# set LDFLAGS and CFLAGS to include the libraries and headers for libgccjit
LIBGCCJIT_DIR=$(brew --prefix libgccjit)
export CFLAGS="-I$LIBGCCJIT_DIR/include"
export LDFLAGS="-L$LIBGCCJIT_DIR/lib/gcc/10"

./configure --with-nativecomp --with-xwidgets

# 20FEB21 - gccemacs - Fast bootstrap is now active by default https://akrl.sdf.org/gccemacs.html
# NATIVE_FULL_AOT=1 should be used instead of NATIVE_FAST_BOOT=1
# not passing bindir to make results in dlopen failures

make -j16 NATIVE_FULL_AOT=1 bindir=/Users/bobrien/src/gnu-emacs/28/gccemacs/nextstep/Emacs.app/Contents/MacOS

make -j16 install

These are the substantially different build times of make bootstrap versus make
# ./build.sh  28625.69s user 592.94s system 1157% cpu 42:03.62 total (with make bootstrap)
# ./build.sh     99.15s user  58.67s system  146% cpu  1:47.39 total (with 'just' make)


texts: How to feed range from org-table filled with strings to code-block via tblfm?

texts:
Following Situation:

I would like to calculate some fields from an org-table filled with strings.
There are many tables which all could share the same lisp-code.
The lisp-code is rather complex and long.
It should run for a single table multiple times, but with different parameters.
I would like to share the org-document along with calculation-ability.

Is it possible to achive this? If so how to achieve this?

I have done some simple tests to show you where my problem is:

#+NAME: test3
#+BEGIN_SRC emacs-lisp :var x="foobar"
(length x)
#+END_SRC

#+TBLNAME: test3-tbl
| blahbar |   |
| testi   | 7 |
#+TBLFM: @2$2='(org-sbe test3 (x $@1$1))

The above code works it takes one string from the table and prints its length into the table, fine.

Next code is also working:

#+NAME: test5
#+BEGIN_SRC emacs-lisp :var x='(2 3)
(* (car x) (cadr x))
#+END_SRC

#+TBLNAME: test5-tbl
| 4 |  5 |
|---+----|
| 6 | 20 |
#+TBLFM: @>$1='(org-sbe test5)::@>$2='(org-sbe test5 (x @1$1..@1$2))

It takes a range of numbers from the table and does some calculation, fine.

Now I tried to combine the stuff from above, and there I hit the wall.
How to give a range (fields @1$1 to @1$2) from test-tbl4 to code-block test4?

#+NAME: test4
#+BEGIN_SRC emacs-lisp :var x='("foobar" "barfoo")
(concat (car x) (cadr x))
#+END_SRC

#+TBLNAME: test4-tbl
| blahbar      | test   |
| foobarbarfoo | #ERROR |
#+TBLFM: @>$1='(org-sbe test4)::@>$2='(org-sbe test4 (x $@1$1..$@1$2))

As you can see by #ERROR it is not working.

So my Questions:

How get table test4-tbl to work with code-block test4?
And could you please point me to the documentation where this is described?


texts: "Failed to get project GHC version:CradleError" cabal haskell project is not working fine with haskell-language-server-wrapper

texts:
I've installed haskell platform in my linux system using ghcup.
I've setup language server configuration for haskell which is github like this.
Then I've created a cabal project
   mkdir cabal_project && cd cabal_project

   cabal  init

When I opened the cabal_project in emacs, the lsp server for haskell is starting and it errors out.

Server lsp-haskell:44680/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)

Here are the logs for lsp -

lsp-haskell::stderr
lsp-log
lsp-log: lsp-haskell:35968

I tried opening non cabal project with one first.hs file and it is working fine.
I don't know what is the problem with cabal project.
How can I fix this issue?
haskell-language-serverwrapper details -
$ haskell-language-server-wrapper --version                                       00:33:00
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /home/rajkumar/.ghcup/bin/haskell-language-server-wrapper-1.0.0) (GIT hash: 4cd1cf934638881e52b3eba9f70157a4b799c0e9)

Linux OS details -
lsb_release -a                                                                    00:33:10
LSB Version:    1.4
Distributor ID: Garuda
Description:    Garuda Linux
Release:        Soaring
Codename:       n/a


texts:
I've been trying evil mode in emacs. Unfortunately, it does not remind me to "Help poor children in Uganda!" when I start emacs.

Is there a simple way to simulate this? Hopefully there's just a setting for evil-mode.

Update

Thanks MrBones

I find it very soothing...


texts: How to customize DONE headlines per-file in org-mode?

texts:
I would like to customize the headline and keyword inside of an org file. In this question is shown how to change the faces of each keyword, but not the headlines.

For the moment, I haven't achieve it and I don't have any idea what to do?

I have the 9.2 version of org-mode.

The header in my org file is:

#+TODO: TODO(t!) HIGHLIGHT(h!) WAIT(w@/!) | DONE(d!) CANCELED(c@)

And the footer is:

# Local Variables:
# org-fontify-done-headline: t
# org-todo-keyword-faces: (("TODO" . org-warning)
#                          ("HIGHLIGHT" . (:foreground "yellow" :background "red" :weight bold))
#                          ("WAIT" . "yellow")
#                          ("CANCELED" . (:foreground "red" :background "white" :weight bold))
#                          ("DONE" . (:foreground "green" :strike-through t)))
# End:

PS: I can change the faces for the keywords HIGHLIGHT, WAIT and CANCELED. However, the TODO and DONE items keep unchanged.


texts:
I am trying to match a Perl identifier at the point, like My::Module::dummy_func. I'd like to start simple and require a valid identifier as follows:

restricted to a single line
starts with a space
ends with a (

So if point is at a colon in this line:

my $a = My::Module::dummy_func(3)

I should get a match equal to My::Module::dummy_func.

Here is what I have

(defun get-perl-id-at-point ()
  (interactive)
  (let ((beg nil) (end nil))
    (save-excursion
      (if (re-search-forward "[A-Za-z0-9:_]*?(" (line-end-position) t)
          (setq end (- (point) 1))))
    (save-excursion
      (if (re-search-backward " [A-Za-z0-9:_]*?" (line-beginning-position) t)
          (setq beg (+ (point) 1))))
    (if (and beg end)
        (message (buffer-substring beg end)))))

This works for example if point is at a :, but if point is at the $ in $a I get $a = My::Module::dummy_func whereas I would like to get a no match..

How can this be done?


texts:
Q: can I put divider lines in my org agenda view?

My agenda buffer can get a little busy when I have a lot of things due.  This busyness has the counterproductive effect of making me avoid looking at my agenda because it freaks me out.  I'm looking for a way to make it visually less daunting.

One thing I'd like is to be able to put divider lines (eg, just a line of dashes) in between agenda items that:

have a deadline today,
are past their deadline (overdue X days), and
have an upcoming deadline (due in X days).

Is it possible to put divider lines in the agenda view?  If yes, how would I do that?


texts: How to delete a single column cell in an org-mode table?

texts:
In Excel etc it is possible to delete a cell in a column and have the cells below it "shift up" without affecting the content of the other columns. I haven't found a command for this in org-mode, is there one?
Example: In the following table I want to delete the cell Banana.
| Cars  | Fruits |
|-------+--------|
| Volvo | Apple  |
| Saab  | Banana |
| Ford  | Pear   |

This should be the result:
| Cars  | Fruits |
|-------+--------|
| Volvo | Apple  |
| Saab  | Pear   |
| Ford  |        |

Now ideally if I were to additionally delete Volvo the table would look like this:
| Cars | Fruits |
|------+--------|
| Saab | Apple  |
| Ford | Pear   |


texts: Buffer-local hook shadowing default value for subsequently loaded libraries

texts:
After having a problem with debugging a package I write, I finally tracked down the problem to the following: auto-revert-mode is making kill-buffer-hook buffer-local (which is fine by me). The  problem is that every library (auto-)loaded afterwards (while the buffer is still active) only "sees" the buffer-local binding, and any add-hook only modifies the buffer-local binding.

Here are a few steps to reproduce the problem using only standard emacs libraries:

(find-file "foo.el")

kill-buffer-hook                  ; => (uniquify-kill-buffer-function vc-kill-buffer-hook)
(default-value 'kill-buffer-hook) ; => (uniquify-kill-buffer-function vc-kill-buffer-hook)

;; Turn on `auto-revert-mode': `kill-buffer-hook' becomes buffer-local
(auto-revert-mode)

kill-buffer-hook                  ; => (auto-revert-notify-rm-watch uniquify-kill-buffer-function vc-kill-buffer-hook)
(default-value 'kill-buffer-hook) ; => (uniquify-kill-buffer-function vc-kill-buffer-hook)

;; Subsequently load a library which adds a `kill-buffer-hook'
;;   only the local binding is modified; no other buffer will ever see
;;   the hook installed by `tramp'
(require 'tramp)

kill-buffer-hook                  ; => (tramp-delete-temp-file-function auto-revert-notify-rm-watch uniquify-kill-buffer-function vc-kill-buffer-hook)
(default-value 'kill-buffer-hook) ; => (uniquify-kill-buffer-function vc-kill-buffer-hook)

;; The same thing happens (unsurprisingly) for auto-loaded libraries
(browse-url "emacs.stackexchange.com")

kill-buffer-hook                  ; => (browse-url-delete-temp-file tramp-delete-temp-file-function auto-revert-notify-rm-watch uniquify-kill-buffer-function vc-kill-buffer-hook)
(default-value 'kill-buffer-hook) ; => (uniquify-kill-buffer-function vc-kill-buffer-hook)

So I guess my question is: is this normal and desired behaviour? Shouldn't all buffers see the hooks installed by subsequently loaded packages?

Although the problem here is specifically caused by auto-revert-mode and kill-buffer-hook, I'm guessing this situation is fairly more general and could happen for a lot of libraries and hooks...


texts: Fresh install of emacs 24.5.1 and Prelude not working because melpa wont download on OS X 10.11.2

texts:
I have a fresh install of Emacs 24.5.1 on OS X 10.11.2 and when I install prelude (https://github.com/bbatsov/prelude) via the recommended auto-magic way (curl -L https://git.io/epre | sh) then open emacs I get an error:

Warning (initialization): An error occurred while loading `/Users/caseyallred/.emacs.d/init.el':

error: Package `anzu-' is unavailable

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.

If i then run M-x list-packages it says that it Failed to download `melpa` archive

I'm a bit of Emacs noob and I have no idea how to fix it.

Thanks in advance


texts: Org mode - do statistic with remote table

texts:
Can we do statistic with remote table?

Say TBL2 row1 is min of TBL1 columns,TBL2 row2 is max of TBL1 columns.
I write formula as below but it doesn't work!

#+NAME: TBL1
|  2 |  3 |
|  4 |  5 |
|  7 | 10 |
| 12 | 1  |

#+NAME: TBL2
| #ERROR | #ERROR |
| #ERROR | #ERROR |
#+TBLFM: @1$1='(seq-min remote(TBL1,$1))::@1$2='(seq-min remote(TBL1,$2))::@2$1='(seq-max remote(TBL1,$1))::@2$2='(seq-max remote(TBL1,$2))

expected output is:

#+NAME: TBL2
|  2 |  1 |
| 12 | 10 |


texts: Starting a shell then cd to a specific directory

texts:
I want to go to a specific directory after I start a shell. So I put these lines in my .emacs file:
(shell)
(shell-command "cd C:/MyStartUp/ThisDirectory")
(setq default-directory "C:/MyStartUp/ThisDirectory")

However, whenever I start emacs, the shell ends up in this directory
c:\emacs-26.3\bin>
How do I fix this?


texts: What is the equivalent of "\n\t " in string mode in re-builder?

texts:
This webpage recommends being in the string mode when using re-builder, the interactive regexp builder, where one does not have to use "\" to escape special characters.

But how does one convert newline and tab characters in, say, this regexp "\\([^\n\t '()\"]*\\)" in read mode to string mode? This question also applies to all characters that becomes special characters after the backslash.


texts: I want to save an email receipt as a PDF. I type a and v (for Action and View as PDF) and get Wrong type argument: stringp, nil. How can I save a message as a PDF file?


texts: `ispell-dictionary-base-alist` and `ispell-dictionary-alist`: how to add utf-8 cyrillic charachter codes?


texts: Show compilation errors in "#+RESULTS" code blocks

texts:
The problem
I'm currently writing notes on C++ classes. Sometimes I annotate what I shouldn't do (because they cause compilation errors) so it would be really helpful if I could automatically insert compilation errors in the #+RESULTS section of source code blocks.
Consider the following example: I would like the following code block to produce
#+begin_src cpp
class A {
  static int n = 0;
};

int main() { return 0; }
#+end_src

this #+RESULTS code block
#+RESULTS:
#+begin_example
/tmp/babel-NYqDkg/C-src-HslBxN.cpp:11:14: error: ISO C++ forbids in-class initialization of non-const static member ‘A::n’
   11 |   static int n = 0;
      |              ^
#+end_example

Additional context
In sh source code blocks, I can accomplish a similar behavior by using the following header arguments
#+begin_src sh :prologue "exec 2>&1" :epilogue ":"
ls "this path doesn't exist"
#+end_src

#+RESULTS:
#+begin_example
ls: cannot access "this path doesn't exist": No such file or directory
#+end_example


texts: Org Mode & Evil: Prevent editing of hidden text within collapsed subtree

texts:
I know that this can be avoided easily, in fact there is a previous question here that covered this matter before, but this only works if we are using Emacs without Evil or using Evil with the emacs-state.

I have this in my init.el:

  (setq-default org-catch-invisible-edits  'error
                org-ctrl-k-protect-subtree 'error)

and works perfectly fine without Evil. So, my question is:

How can I make this work with Evil without use emacs-state?


texts: Spacemacs: Error `Wrong type argument: commandp, org-set-tags` when setting tag

texts:
I was not sure if this is a Spacemacs issue or a local configuration issue, hence I figured I would post to Emacs Stackexchange.

When I use the Spacemacs key SPC-m : to try and add a tag to an orgmode bullet point (or subtree heading), I get this error: Wrong type argument: commandp, org-set-tags. However, when I use the normal Orgmode key combination C-c C-q the tag will insert just fine.

I updated Spacemacs and the set of packages as well, but still getting the error. Not sure what would be causing this.


texts:
Today I decided to install emacs and give it a try. I followed some tutorials/examples/explanations and managed to install Python Jedi for getting suggestions while coding / code completion. It does that nicely, but there is one issue with it. The list with the completion suggestions is so wide, that the documentation strings don't have any space anymore and are squeezed into a single column. A screenshot will help to show what I am talking about: screenshot

Any ideas how I could fix this? (Keep in mind, I only installed emacs today and it's totally new to me.)

After solving the issue, my .emacs file contains these lines

(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
(setq jedia:ac-max-width 0.5) ; This line solved the issue.


texts: I'm using Spacemacs, in term mode and on a mac. While I can adjust the standard font size I am often moving from/to a different monitor, and I want to be able to tweak the font size for the moment. Is there an easier way than changing the font size in my config file?


texts: Why does *compilation* buffer show control characters?

texts:
I'm using the *compilation* buffer to build a C++ application on Centos 5 and Centos 6.  The buffer shows the build and includes references to files that are part of the build.  However, I'm getting control characters like ^[ appear in the output and it is hard to read and emacs is getting corrupted filenames when you click one in the output. I think these characters are some kind of coloring or other annotation on the compiler output but I don't know where they are coming from.  Here is sample output:

cc -c -g -I../machind -I. -DRELEASE_VERSION -g -O2 -m64 -D__BITS64 -pipe -DARCH_64 -DARCH_INTEL -DARCH_X86 -DARCH_X86_64 -DOS_LINUX -pthread -DLM_INTERNAL -DFLEXLM_KITBUILD -DFLEX_STATIC -DRELEASE_VERSION -DGPLATFORM=\\"x64_lsb\\" -DLINUX -DLSB3_0 -D__FD_SETSIZE=65535 -DGLIBC -DLINUX64 -DAMD64 -DREDHAT -DREL -DRHLINUX64 -DPLATFORM_AMD64_RHLINUX   -DNO_ACTIVATION_SUPPORT ../machind/lmcrypt.c
^[[01m^[[K../machind/lmcrypt.c:^[[m^[[K In function  ^[[01m^[[Kmain^[[m^[[K :
^[[01m^[[K../machind/lmcrypt.c:156:47:^[[m^[[K ^[[01;35m^[[Kwarning: ^[[m^[[Kcast to pointer from integer of different size [-Wint-to-pointer-cast]
     lc_set_attr(lm_job, LM_A_MAX_LICENSE_LEN, (LM_A_VAL_TYPE)max);
^[[01;32m^[[K                                               ^^[[m^[[K

How can I get rid of the non-text output in my compilation buffer?


texts: Can't success ./configure on CentOS 7: configure: error: You seem to be running X, but no X development libraries

texts:
CentOS 7
I want to install Emacs 26.3 on CentOS.
Here instruction
https://www.gnu.org/software/emacs/manual/html_node/efaq/Installing-Emacs.html

Download Emacs 26.3 from here https://ftp.gnu.org/pub/gnu/emacs/

Extract from archive like this.
tar -zxvf emacs-26.3.tar.gz

cd emacs-26.3

./configure

But I get error:
...
checking for struct ifreq.ifr_netmask... yes
checking for struct ifreq.ifr_broadaddr... yes
checking for struct ifreq.ifr_addr... yes
checking for struct ifreq.ifr_addr.sa_len... no
checking whether gcc understands -MMD -MF... yes
checking for X... no
checking for X... true
configure: error: You seem to be running X, but no X development libraries
were found.  You should install the relevant development files for X
and for the toolkit you want, such as Gtk+ or Motif.  Also make
sure you have development files for image handling, i.e.
tiff, gif, jpeg, png and xpm.
If you are sure you want Emacs compiled without X window support, pass
  --without-x
to configure.


texts: How to show all split window titles in the X11 window title?

texts:
If I split an Emacs frame (one X11 window) into multiple Emacs windows (with C-x 2 and C-x 3) and open different Emacs buffers in different Emacs windows, Emacs frame title (X11 window title) displays only the name of the currently active buffer. (Hope I got Emacs terminology right.)
For example: assume I have three buffers open in one X11 window: a.txt, b.txt and c.txt. X11 window title will be a.txt if I have a.txt buffer active. I instead want it to be a.txt, b.txt, c.txt or any other string that contains all the split buffer names.
Motivation: I use rofi -show window to search for windows and I often can't find an Emacs window I look for because it has the wrong split active at the moment.


texts: How to bind-pack list of null terminated strings?

texts:
According to the bindat spec docs, there are two specs to pack
strings. They are str and strz. Both are for a fixed length
string.

Now, suppose I want to pack ("some" "list" "of" "string), I should
do this:

(bindat-pack
 '((elem0 strz 5)
   (elem1 strz 5)
   (elem2 strz 3)
   (elem3 strz 7))
 '((elem0 . "some")
   (elem1 . "list")
   (elem2 . "of")
   (elem3 . "string")))

But that is so inflexible for several reasons:

I have to put name and length manually.
strz need to know size of the string before hand instead of just
calculate the length of given string.

There are vec and repeat in the bindat spec but both are the same,
both need length of the list before hand.

So far, I've come up with this:

(require 'seq)
(require 'bindat)

(defun make-strz-spec (name value)
  (let ((value (cond ((stringp value) value)
                     ((symbolp value) (symbol-name value))
                     (t (error "%s is neither string nor a symbol" value))))
        (sym (make-symbol name)))
    `((,sym strz ,(+ 1 (string-bytes value)))
      (,sym . ,value))))

(defun make-strz-spec-list (string-list)
  (seq-map-indexed
   (lambda (str idx)
     (let ((name (concat "elem-" (number-to-string idx))))
       (make-strz-spec name str)))
   string-list))

(defun bindat-pack-list-of-string (string-list)
  (let ((spec-pair (make-strz-spec-list string-list)))
    (bindat-pack
     (mapcar (lambda (elem) (nth 0 elem)) spec-pair)
     (mapcar (lambda (elem) (nth 1 elem)) spec-pair))))

;; this
(bindat-pack-list-of-string '("some" "list" "of" "string"))

But, that introduces more functions globally with very specific
purpose. I don't want to pollute programming environment just for
this.

Since I am still new with emacs-lisp and lisp in general. I am sure
there's a better way than mine.

So, back to my main question, how can I bind-pack list of null
terminated string?


texts: use-package - load package depending on the OS username

texts:
I am not a Java guy at all, but I mess with it quite often for university reasons. I have used this awesome post by peter goldsborough to set up eclim. Which is nice! But this also requires a lot of setup in order to work. I have also use this awesome package called maghanada to set up a cool java environment that is much more portable but lacks refactoring features.

I wish I could load eclim, if my current username is cescoferraro, meaning I am on one of my machines. And load meghanada if I am somewhere else where I am usually just an id number like 34252354, and probably wont have neither time nor permission enough to perform a eclim installation.

(use-package eclim :ensure t :if (not(equals os/username "cescoferraro")) :config (progn (...)))
(use-package mehganada :ensure t :if (equals os/username "cescoferraro") :config (progn (...)))


texts:
When I follow from one Org file to another via a link, the new file appears in alternative window if there is one. Is there a way to follow links staying in the same window?
For example, I use a frame with two horizontally split windows. Left is for code, right is for docs in Org format. If I follow a link in the right window, the new Org file is opened on the left side, and I do not see the buffer with a code anymore.


texts: Magit: enable `toggle-truncate-line` in diff-mode

texts:
I'm working with tex files that have usually long lines of text. I enabled in magit the fine coloration of errors by using:

(setq-default magit-diff-refine-hunk 'all)

and now I'd like to disable the truncate-line function. How could I do that?

Thanks!


texts:
Complete emacs beginner here. Just installed emacs in my Manjaro (awesomewm edition) machine using pacman.
The emacs window is almost completely transparent, I can't read anything. If started from a terminal, it raises these errors:
(emacs:4193): Gtk-CRITICAL **: 23:20:57.211: _gtk_css_image_get_concrete_size: assertion 'default_width > 0' failed

(emacs:4193): Gtk-CRITICAL **: 23:20:57.211: _gtk_css_image_get_surface: assertion 'surface_width > 0' failed

(emacs:4193): Gtk-CRITICAL **: 23:20:57.211: _gtk_css_image_get_concrete_size: assertion 'default_width > 0' failed

(emacs:4193): Gtk-CRITICAL **: 23:20:57.211: _gtk_css_image_get_surface: assertion 'surface_width > 0' failed

(emacs:4193): Gtk-CRITICAL **: 23:20:57.211: _gtk_css_image_get_concrete_size: assertion 'default_width > 0' failed

(emacs:4193): Gtk-CRITICAL **: 23:20:57.211: _gtk_css_image_get_surface: assertion 'surface_width > 0' failed

Any clues on what's wrong?
Screenshot:

Note: also tried installing emacs with another package manager (guix) as a foreign package manager. Still got the same problem.


texts: Backward quote, what does it mean in elisp?

texts:
I was referring the source code of switch-to-buffer in elisp source code, window.el.gz. I am seeing some backward single quotes like, `

I know single quote is used to refer to symbols but what does backward single quote do?

Source code is here. When to use backward quote in elisp?

Reproducing the same here,

       ((pcase switch-to-buffer-in-dedicated-window
          (`nil (user-error
                 "Cannot switch buffers in a dedicated window"))
          (`prompt
           (if (y-or-n-p
                (format "Window is dedicated to %s; undedicate it"
                        (window-buffer)))
               (progn
                 (set-window-dedicated-p nil nil)
                 'force-same-window)
             (user-error
              "Cannot switch buffers in a dedicated window")))
          (`pop nil)
          (_ (set-window-dedicated-p nil nil) 'force-same-window)))


texts: How do I disable ffap (find file at point) when the first two non-space characters in a line are '//'?

texts:
In Verilog/C/C++, comments can begin with //.

Here's an example comment,

//This is a comment

I like to use the find-file-at-point feature. If my cursor is on the file name in `include "some_file.v".

But if my cursor is on the above example comment and if I hit C-x C-f, emacs tries to open a tentative path //This!

How do I selectively prevent find-file-at-point from activating? In this case, when the major mode is verilog-mode, how do I NOT do find-file-at-point when my cursor is on a line where the first 2 non-space characters are //?


texts:
I'm working under org-mode.

When I click on a [http://example.com] link, it opens a tab in Firefox as expected. The .emacs config is: '(browse-url-browser-function (quote browse-url-firefox))

However, for links in the form file:///localdir/myfile.html it depicts the message running /usr/bin/sensible-browser and starts Opera.

Why would emacs do that? Why does it not use Firefox or defaults to my system default browser?


texts: The C-x C-j binding for dired-jump stopped working

texts:
I used to have a keyboard shortcut for the following action:

  "Open the folder containing this file in Dired+, and place point (cursor) on the file"

I believe it was C-x C-j, and I don't recall setting it up manually. It seems to be gone. Did recent changes to Dired+ perhaps change this?

Either way, are there any Dired or Dired+ built-in interactive functions that I could use for this? If not, how can I go about building one?

I can run M-x dired-jump. The problem seems to be that the keybinding is gone.
When I do C-h k C-x C-j RET, I see C-x C-j RET (translated from C-x C-j <return>) is undefined.


texts: Open multiple *SQL* buffers (same product)

texts:
I connect to postgres by placing the following in a file on a remote server, opening over tramp, and executing:

(setq sql-connection-alist
      '((pool-my_db
         (sql-product 'postgres)
         (sql-server "localhost")
         (sql-user "postgres")
         (sql-password "postgres")
         (sql-database "my_db")
         (sql-port 5432))
))

;; emac25:
(sql-set-product-feature 'postgres :prompt-regexp "^.*=# ")

(defun sql-connect-preset (name)
  "Connect to a predefined SQL connection listed in `sql-connection-alist'"
  (eval `(let ,(cdr (assoc name sql-connection-alist))
    (noflet ((sql-get-login (&rest what)))
      (sql-product-interactive sql-product)))))

(sql-connect-preset 'pool-my_db)

If I execute the same script in the context of a different remote server, it just switches to the buffer for my first session.  Is there a way to open subsequent SQL sessions in a new  buffer so I can have multiple remote sql shells open at the same time?


texts: Variables in Babel evaluation with SQL blocks

texts:
According to the org-mode manual, you can set variables in code blocks
as follows:

#+HEADERS: :var foo="blah"
#+BEGIN_SRC elisp
(message foo)
#+END_SRC

#+RESULTS:
: blah

However, when I try to do this with a babel block with SQL, I have no
good luck:

#+HEADERS: :var foo="blah"
#+BEGIN_SRC sql
SELECT foo
#+END_SRC

I get the predictable error:

Error: No such column: foo

The output I'd like to see is something like:

blah

In the *SQL* buffer. I've spent a lot of time trying to figure it
out but I haven't made any progress yet.

So is what I'm trying to do possible with SQL?

Thanks!

Edit: based on the comments below, the following does work after I explicitly load ob-sqlite:

#+HEADERS: :var foo="blah"
#+BEGIN_SRC sqlite :db ":memory:"
SELECT "$foo";
#+END_SRC

#+RESULTS:
: blah

The problem is that I have a connection in the SQL buffer that I want to reuse rather than hard-code the path to the database via :db since I am executing the same query on multiple databases.

Almost there!

Edit 2: In the end, I ended up doing this:

#+HEADERS: :var foo="blah"
#+HEADERS: :var bar="boop"
#+BEGIN_SRC sqlite :header yes :db (some-lisp-call-here)
SELECT $foo, $bar;
#END_SRC

I can live with this but I went further and factored out the common parameters

# -*- org -*-
#+PROPERTY: header-args:sqlite :header yes :db (some-lisp-call-here) :var foo="blah" :var bar="boop"


texts: Determine if a directory is .gitignored with vc

texts: I would like to determine if the current directory/file is ignored by .gitignore with vc. In this case, only git matters, but of course a general solution would be appreciated.


texts: orgmode open link in system browser or eww

texts:
I want orgmode web links to open in my system browser with C-o, and to open in eww with C-u C-o. This seems in line with the function description for org-open-at-point but it doesn't seem to be working. I've tried various permutations of the following, but can't seem to get behavior that allows me to choose between firefox and eww based on C-u args. The following seems to always open in eww, regardless.

(setq browse-url-generic-program (executable-find "firefox")
      browse-url-browser-function 'eww-browse-url)


texts: How are major modes and local keymaps associated?

texts:
The Emacs manual says:

  Major modes customize Emacs by providing their own key bindings in
  local keymaps.... Minor modes can also have local keymaps...

Roughly, it seems to say:

  Major modes provide local keymaps. Minor modes have local keymaps.

I understand the idea of major and minor modes: A buffer has one major mode and possibly (usually) several minor modes which apply small modifications.

I am confused about the terminology "local keymap". For a time I thought "major" and "local" were somewhat synonymous. This was confusing because "major" implies big and important and "local" implies small and less important.

I then looked at the rules for looking up keybindings which are roughly:

 (or (if overriding-terminal-local-map
         (find-in overriding-terminal-local-map))
     (if overriding-local-map
         (find-in overriding-local-map)
       (or (find-in (get-char-property (point) 'keymap))
           (find-in-any emulation-mode-map-alists)
           (find-in-any minor-mode-overriding-map-alist)
           (find-in-any minor-mode-map-alist)
           (if (get-text-property (point) 'local-map)
               (find-in (get-char-property (point) 'local-map))
             (find-in (current-local-map)))))
     (find-in (current-global-map)))

It looks like minor mode keymaps are found in minor-mode-map-alist and minor-mode-overriding-map-alist, and that major mode keymaps are found in current-local-map. All three of those are "local" variables, right? Which means any modifications to them are visible only to the current buffer. Do I understand that correctly?

If that is the case, then the keymaps do no belong to a major mode (or minor mode), they simply belong to buffer local variables.

Which brings me to my (somewhat vague) question: How are modes and keymaps associated?

To pick a specific example. How are emacs-lisp-mode, emacs-lisp-mode-map, and current-local-map related?

Is emacs-lisp-mode-map merely a template that initializes current-local-map? Is current-local-map an independent copy? Or do all buffers using emacs-lisp-mode share the same current-local-map?


texts: Using link abbrevations for EXPORT_FILE_NAME?

texts:
on orgmode 8.3.2 I've got a large org-file. Offen, I need to export a subtree like this:

* Subtree to be exported
:PROPERTIES:
:EXPORT_FILE_NAME: /PATH/TO/FOLDER/filename
:EXPORT_TITLE:
:END:

foo

I'd like to save the exported file in a project folder, as you can see in
EXPORT_FILE_NAME . This is a different folder than folder where my large org file resides.

It would be very helpful to use link abbrevations in EXPORT_FILE_NAME :

(setq org-link-abbrev-alist
   '(("anglisky" . "~/Path/whereever/%s")))

in .emacs and write:

* Subtree to be exported
:PROPERTIES:
:EXPORT_FILE_NAME: anglisky:filename
:EXPORT_TITLE:
:END:

foo

Possible? Feature Request?

The trick in my org-link-abbrev-alist is that the path depends, e.g. on the OS of the computer. Under Windows, the path  may be X:/..., under Linux the path is /home/<user>/whatever/else/

So it would be very helpful to use link abbrevation for the export file name.

I've been asking this question on the orgmode-mailing-list, but without an answer.

EDIT

There has been an answer on the orgmode mailinglist: no, it is not possible to use the link abbrevations for the properties list. Sorry, I can't provide a link, Gmane seems to be down.

What a pity, but I'll find another way.

Thank you!


texts: Opening multiple files from the command lines puts the buffer order in the middle

texts:
Let's say I have a Linux directory that looks like

-rw-r--r--  1 hooked se     0 Sep 16 16:02 a
-rw-r--r--  1 hooked se     0 Sep 16 16:02 b
-rw-r--r--  1 hooked se     0 Sep 16 16:02 c

When I type emacs * it opens all three files but it puts me in the middle of the buffer chain. For example when I run it, I start off at c and NextBuffer takes me along the chain

c -> b -> *Messages* -> *scratch* -> a ->

This is really, really annoying. I'd like to open up emacs and have the order be any of the permutations

c -> b -> a -> *Messages* -> *scratch* ->
b -> a -> c -> *Messages* -> *scratch* ->
a -> b -> c -> *Messages* -> *scratch* ->
...

Is there a way I can open up files along the "start" of the buffer list? I'm opening the files from a Bash CLI Ubuntu 14.04 if that makes a difference.


texts: When should I use with-eval-after-load in my configuration files?

texts:
I went over my configuration files and wanted to do some cleanup.

My understanding of with-eval-after-load was that its body would be evaluated right after the related package is loaded. While cleaning up my configurations files and splitting them even more, I wanted to enclose every package configuration with with-eval-after-load. Everything went as expected until I enclosed the configuration for helm and helm-projectile.

Here is what I had in mind (lisp/init-helm.el):

(with-eval-after-load 'helm
  (setq helm-mode-line-string "")
  (add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
  (define-key global-map (kbd "C-c m") 'helm-imenu)
  (define-key global-map (kbd "C-x b") 'helm-buffers-list))

(with-eval-after-load 'helm-command
  (global-set-key (kbd "M-x") 'helm-M-x))

(with-eval-after-load 'helm-projectile
  (helm-projectile-on))

After restarting Emacs, I get this window size issue:

This is how I resize my window:

(set-frame-parameter nil 'fullscreen 'fullboth)

I'm guessing I am misusing with-eval-after-load, how would one sanitize his Emacs configuration and make sure nothing breaks no matter what package are installed ?


texts: Toggle minor mode with a custom keybinding

texts:
I'd like to be able to toggle M-x font-lock-mode with a custom keybinding like C-c l for example (or any minor mode for that matter).

Can this be done relatively easily?


texts: How to customize major mode initialization with local variables?

texts:
Seems like most major modes clear all local variables before initializing. It also seems like many major modes read variables while initializing to customize their behavior.

If I want to set a file or directory local variable to determine major mode behavior (for example, overwriting web mode's web-mode-engines-alist in .dir-locals.el), how can it be done so that the local variables are written before the major mode actually initializes, but are not cleared?

One way to do it would be to bind/rebind global variables using ((nil . ((eval . ((lambda () (setq name val))))))) in .dir-locals.el. The nil key seems to run before any major-modes are entered. Still, it doesn't seem ideal to overwrite global config. For example, maybe I want to work on multiple projects in the same emacs instance.


texts: Disable auto-backup only for certain files

texts:
As of How to stop auto backup in some directory in Emacs, it's possible to configure emacs to backup conditionally.

Is there an option to set inside the file, in the first line, to disable backup for this file only?


texts: How to determine the size of packages installed from ELPA/MELPA?

texts:
When one wants to choose between two Emacs packages that have similar features, it can be useful to evaluate their respective installed size before installing.
How to evaluate the installed size of a package that resides in ELPA or MELPA?
Would there be a way to do so from the list-packages interface?


texts: how to automatically remove org-emphasis markers, i.e. org-deemphasize?

texts:
There is a function org-emphasize, which wraps selected text in org-emphasis markers. (Though I personally use a similar function called wrap-region.)

Is there a function org-deemphasize (or analogously, unwrap-string-at-point) that will remove org-emphasis markers before and after point? (Without my having to manually select the exact region?)

It should refer to org-emphasis-alist For example, my customized org-emphasis alist looks like this:

(("*" bold)
("/" italic)
("_" underline)
("=" org-code verbatim)
("~" flyspell-incorrect)
("+"
(:strike-through t)))


texts: In org-mode, how do I export to JIRA wiki markup?

texts:
The org-mode Worg site, org-export-generic , says that there is a wikipedia exporter. I tried to run it with M-x org-export-generic but i'm getting a 'Cannot open load file:org-export-generic' error.

I need to get my current .org file to export to a Jira Wiki Markup using export so I can put it on a JIRA description.

I'm using emacs24.3.1 on windows 7.


texts: execute named org-bable source block from elisp

texts:
I want to execute selected source blocks in the active buffer.
For example for the following org-mode file,

#+NAME: snippet1
#+BEGIN_SRC emacs-lisp
    (message "snippet 1")
#+END_SRC

#+NAME: snippet2
#+BEGIN_SRC emacs-lisp
    (message "snippet 2")
#+END_SRC

I can use

(org-babel-execute-buffer)

to execute both blocks from elisp, but how can I execute snippet1 without executing snippet2?

I found the following related functions that might help.

org-babel-get-src-block-info
org-babel-execute-src-block

Any pointers to relevant documentation is very much appreciated.


texts: regexp: exclude repeated characters for highlight - hi-lock-mode

texts:
I want to search using regexp to capture plain text. I want to capture passages that begin with opening quotation marks and end at the end of the paragraph, and even though the quote continues onto a new paragraph, I want to capture only the first part (In the following: The dog wagged it's tail.) Note that there are no closing quotation marks at the end of the paragraph because the quote itself continues.
Bob said: ``The dog wagged it's tail.

``But that's not the end of my story,'' said Bob, continuing.

I say I want to "exclude repeated characters" because I don't want to capture to the end of the paragraph when the quote closes, i.e., when there are closing quotes, thus:
''

In other words, I want to accept single apostrophes but not double apostrophes.
Edit: Now that I have this solution, provided by phils below, here's the complete result:

And once the file is loaded, enable hi-lock:
M-x hi-lock-mode
Also: M-x customize-group RET hi-lock-faces


texts: Parse command line arguments in interactive session

texts:
I'd like to pass some extra information to my init.el via command line arguments. However, the variable command-line-args-left is always nil when Emacs is run interactively. (Though it is correctly populated when run with the --script option).

How can I get a list of command line arguments when Emacs is run normally?


texts: disable specific warning in flycheck (specifically "#pragma once in main file")

texts:
I'm using flycheck for C++ development, and get the following warning:

#pragma once in main file

In all headers included in a main file.  Searching the webs, I get the impression this has something to do with how gcc and clang (both give the same warning) compile for flymake.

I would like to get rid of this warning.  Is there anything I can do?


texts:
The command kill-whole-line does just what it says.  With a prefix argument, it allows me to kill multiple lines at the same time.

How can I get the same functionality, but with copying instead of killing?


texts: Reverting a hunk without refreshing in Magit Diff

texts:
Typing v in Magit Diff mode causes an often slow and uncecessary refresh. Can this be avoided?
For example when looking at a diff between a range of commits (say origin/mater...HEAD). Typing v (A.K.A. M-x magit-revert-no-commit) applies the reversed hunk to the worktree. The diff between the commits has not changed, but Magit still refreshes the entire buffer. Even if the diff does change, I often would still like to avoid refreshes when I have large diffs that take minutes to refresh.


texts: Strange behavior when killling text in term/multi-term

texts:
multi-term is my current goto when I want a command line in Emacs. However, I have noticed a strange behavior, and I am not sure whether it is a bug, or if it can be configured.

If I type a command at the prompt - or any text for that matter, and kill the text with backward-kill-word (M-BACKSPACE for me), the text no longer shows up, but behaves like it is still there (see the screenshot, and you will know what I mean). This is what happens when I type ls, kill the text with backward-kill-word, type ls again, and hit enter.

A similar, but slightly stranger thing happens when I move to the front of the text and use kill-word. Below is a the result of typing ls, moving to the beginning of the line, killing the text, and typing ls again (notice the cursor position too).

This certainly seems buggy, but I am not sure. This happens in term as well, which is to be expected, so the problem is likely with term and inherited by multi-term. If I just delete one character at a time, nothhing goes wrong (but who has time to delete one character at a time! I use Emacs so I don't have to do such things. I am not an animal!) Also, this only happens in char mode, not line mode, which leads me to believe that maybe it is an intentional feature that I just don't understand. The docs term include the following sentence:

  In char sub-mode, each character (except `term-escape-char') is sent immediately to the subprocess.

I don't actually understand what this means, but sound potentially related...Any ideas what is  going on? Thank you!


texts:
Doom Emacs' s key does not behave like Vim's implementation. In Vim, s deletes the character under the cursor and puts you into insert mode whereas Evil Mode performs a search, similar to f and t.

Is this something that can be changed?
If not, what was the reasoning behind s not working like it does in Vim? It
seems like most bindings work as expected, except for this one.


texts:
I often find myself wanting to exchange some text object with whatever's currently in CLIPBOARD (not necessarily in Emacs' kill-ring, when I copy from other programs). But of course when I do something like dib, it puts what I removed in the CLIPBOARD, overwriting what was in CLIPBOARD (since I didn't first paste it into Emacs), so I can't just P M-y. So I have to copy it again, next time carefully doing PudibP M-y.

This feels inefficient. Is there a built-in way in emacs/evil to, instead of deleting, exchanging what I'm removing with what's in CLIPBOARD/top-of-kill-ring?


texts: Start emacs with Global TODO list along with default org file

texts:
How can I open the global TODO list along side my default Org file.
Even with Desktop Save mode is on, whenever I open Emacs, only the org file reopens, and not the buffer with the global TODO list.


texts: How to disable the "Press M-x..." title line of org-search-view command's output?

texts:
I use GNU Emacs 26.1 and want to remove the following enormous message

Press ‘M-x org-agenda-manipulate-query-add’, ‘M-x org-agenda-manipulate-query-subtract’ to add/sub word, ‘M-x org-agenda-manipulate-query-add-re’, ‘M-x org-agenda-manipulate-query-subtract-re’ to add/sub regexp, ‘C-u r’ to edit

from the *Org Agenda* buffer, which appears after org-search-view command.


texts: Why can't I use rg (ripgrep) in an Org mode source block?

texts:
I have the following source block in my Org mode file:
#+begin_src sh :results output
  exec 2>&1
  mkdir -p /tmp/example && cd /tmp/example
  echo "hello" > world
  rg --color=never 'hello'
  :
#+end_src

However, I never see any output in Org mode. The same code works fine in my shell. I've also compared the environment of both the org-babel-execute:shell results and my shell and they seem to differ only in TERM.
Why doesn't rg output anything when I execute my block?


texts: Is it possible to export highlighted text with pdf-tools?

texts:
When using Skim I can export any kind of pdf annotations, including highlighted text, to a file.

Is it possible to do the same thing with pdf-tools in Emacs?


texts:
Apparently the correct way to set the default font is the following:

(custom-set-faces
 '(default ((t (:family "Raize" :foundry "raster" :slant normal
                :weight normal :height 120 :width normal)))))

But it's not portable, that means I cannot copy and paste on a different init.el on another computer if I don't check the existence of the correct font before.

A solution is to use a conditional. I already modified my emacs configuration to be environment sensitive, but I cannot solve this issue, I mean I did not manage how to correctly extract the statement from the (custom-set-faces ...) block to use within a (setq ...), for instance. Or, as alternative, I wonder if I can use an if() in this case.

Any clue?


texts: Unable to export markdown files with devanagari characters

texts:
Running emacs 25.2.2. And markdown installed from Melpa.

If I export a file with devanagari characters, it produces a file sans devanagari characters!

I did a bit of research and found out that markdown test.md -o test.html issued from a command line does similarly. But pandoc -o test.html test.md works properly. So, this could be a bug in markdown command as provided by discount package on my Kubuntu 18.04.

So, I customized markdown-command to pandoc. That did not help. So, I customized markdown-command-needs-filename to t. That produces gibberish for devanagari characters.

Is there a way out? What do I need to do to get markdown export going?

Or, how do I set pandoc as my command to execute while exporting a markdown file?


texts: Any advice? - Struggling with text reuse in emacs buffer

texts:
I'm basically a level 0 emacs/orgmode user, trying to get the hang of Emacs/Orgmode. Doing this like for the 5th time already, as most Emacs beginners obviously. I have this feeling I'll like and be happy with the Emacs world, but oh well it takes a lot of patience. So I'm trying to do things little by little.

So I'm trying to do something that seemingly should be quite doable but can't understand how to make it work. The idea is to reuse predefined text within a buffer.

I think that what I want is to define kind of "text variables" or "snippets" and reuse that in my text later on.

Let's say I'm writing some specification for my laptop. I'd like to something like define a term in buffer (don't pay attention to syntax, it's just my interpretation), let's say "Thinkpad T470p, black, with dedicated graphics card, XYZ".

So I'd define this term at the beginning of my buffer.

The term, presumably, would have a label/name (not sure if this is the correct term) and some value. Let's say, the value is as above and label is "MyThinkPad".

Then when writing text, I'd like to start writing "MyThinkPad" and that would auto-insert the previously predefined text "Thinkpad T470p, black, with dedicated graphics card, XYZ" at the cursor position.

AND what is most important - if I change value of this "variable" in the buffer , that should auto-update throughout the buffer.

I'm not sure what is the right direction to look. I have a feeling this has to do with some of these "#+NAME" or "#+LABEL", or citations, or local variables, or something of that sort.

After reading online resources and trying out various ideas, I'm stuck and turning to community help. Really looking forward to your suggestions. Thanks in advance!


texts: Empty buffer shows when using emacsclient on windows

texts: I am using GNU Emacs for Windows alongside of cygwin, and I want to set my EDITOR shell variable to be emacsclient -a=.  My problem is that when certain programs try to use EDITOR to launch an editor with some pre-populated text, like git commit, fc, or edit-and-execute-command from bash, the emacs client frame opens with an empty buffer.  How do I get it to show the contents of the file that the program is trying to open?


texts: How to by pass super key cord to system?

texts:
I am using emacs25 on macOS.

How to bypass command key cord, e.g., ctrl-command-/ to system?

Currently it is captured by emacs.


texts:
I have this in my .emacs:

(defalias 'λ 'lambda)

which works fine for simple things like (funcall (λ (x) x) 1).

But when I do something like (org-add-link-type "foo" (λ (s) (message s))) or (add-to-list 'auto-mode-alist '("foo" . (λ () (message "bar")))), it doesn't work and I get

  org-open-at-point: Invalid function: (λ (s) (message s))

and

  File mode specification error: (invalid-function (λ nil (message "bar")))

respectively.

Does anybody know what's wrong here?


texts:
I'm using Spacemacs and multi-term on OS X 10.11. Preferred shell in zsh with oh-my-zsh installed.
In the Spacemacs shell window, there are two weird UI issues:

Command line never scrolls to the bottom, so that i always several empty lines in the bottom of the buffer.
Command prompt has got weird 4m symbols prepended (UPDATE: per lunaryorn's comment, this got fixed by adding export TERM=xterm-256color to .zshrc. Previously echo $TERM yielded eterm).

Both issues are visible in the screenshot attached. Does anyone know how to address these?

Thanks!


texts: How can I set directory local variable in relative to .dir-locals.el file location?

texts:
I often find myself in the situation where I'm told to put relative paths as directory local variable. For example cmake-ide's cmake-ide-project-dir and cmake-ide-build-dir. Of course this is not very portable.

So instead of

.dir-locals.el:

((nil . ((cmake-ide-project-dir . "/home/user/code/project"))))

I want something like

((nil . ((cmake-ide-project-dir . directory-of-current-dir-locals-file))))

How can I define such a variable directory-of-current-dir-locals-file? And how would I set for example cmake-ide-build-dir, which is typically (concat directory-of-current-dir-locals-file "build")?


texts:
I use xref to find tags in emacs 25.

My problem is with C       defines, when there are multiple definitions. The *xref* buffer
       shows suggestions, but does not show enough text (it stops right
       after the identifier).

For example, when looking up PRINTF, one of the found definitions showed in the *xref* buffer
       looks like this:

#define PRINTF(

while the actual code at that location is:

#define PRINTF(FORMAT, args ...) printf_P(PSTR(FORMAT), ## args)

 How do I make the xref buffer show the whole row in the file?

Edit: creating my TAGS with:

;; Shell command: find . -type f \( -name '*.cpp' -o -name '*.[ch]pp' \) | etags -
(defun create-tags (dir-name)
  "Create tags file."
  (interactive "DDirectory: ")
  (shell-command
   (format "cd %s && find . -type f \\( -name \'*.[ch]\' -o -name \'*.[ch]pp\' \\) | etags -" dir-name))
  )


texts: Transform w3m buffer names in ivy-switch-buffer

texts:
emacs-w3m really likes to have its buffers have names like *w3m*<16> or *w3m* so when switching buffers, it's impossible to tell just from the names which buffer is displaying which web page.

I've tried renaming the w3m buffers to their web page titles -- which you can get with (w3m-current-title) -- but ran in to problems when I realized that internally emacs-w3m uses the original buffer titles to both do tab ordering and tab movement, so changing those names (even when leaving in the original w3m buffer names as prefixes) at the very least destroyed my ability to move tabs, so I reverted back to the original names.

Today I realized that for the most part it doesn't matter to me what the buffers are called, as long as when I use ivy-switch-buffer it shows the results of running (w3m-current-title) in place of the corresponding w3m buffer name.

Is there an easy way to accomplish this?

In short, I'm looking for a way for ivy-switch-buffer to filter buffer names through a user-given function before displaying them.


texts: org-babel: define commands for all named source blocks in given set of files

texts:
This answer shows how to define a command that executes a named org-babel source block. If you want to do this for all named source blocks in a file, you could define one command per block. That's cumbersome.
I'm looking for a function that defines commands for all named blocks in a given set of files.

the function should be placed in init.el to define commands for all named source blocks in
a set of files
the command names should prefix something like 'my-org-babel-' to all block names
in case of duplicate block names, the latest one encountered can be retained


texts: Access minibuffer history without using arrow keys

texts: Is it possible to scroll the minibuffer history without using arrow keys?  My preference would be to not have my fingers leave the home row.


texts:
Is it possible to set a default username (i.e.: my Github user name) for magit? It is prompting for the user every time I have to push a commit.

Don't know if this may help with the answer, but I already have my username and my e-mail in ~/.gitconfig as per magit's manual:

  The default is determined by the user.name and user.email git configuration settings.


texts: emacs error on startup when i try and bind keys to wdired-mode-map

texts:
emacs gives me an error when i try the bind keys to wdired-mode-map:

(define-key wdired-mode-map (kbd "TAB") 'my-mark-file-name-forward )
(define-key wdired-mode-map (kbd "-") 'my-mark-file-name-backward )
(define-key wdired-mode-map (kbd "<f2>") 'my-mark-file-name-for-rename )

the error is:

Symbol's value as variable is void: wdired-mode-map

any clue what im doing wrong here? i always define-key for other modes like this an never encountered an issue


texts: Unable to remap key bindings involving meta under iTerm2

texts:
I'm using iTerm2, and I would like to remap some of the meta keys. In my .emacs I have

(global-set-key (kbd "M-g") 'goto-line)

And in my iTerm2 settings I have both "option" keys set to send +Esc. I can use any of the default key bindings like normal, but M-g, (or others I've remapped) still send the default command. I've tried changing iTerm2 to send meta, but it instead injects non-printable ascii characters.

What's the best workaround to get these key bindings to work under iTerm2? Is there a clearer solution than to have my .emacs check if I'm using a Mac, and if so then use (kdb "Esc-g")?


texts: How to build Emacs master branch (aka trunk) on MS-Windows

texts:
I took the plunge today and started out on my quest to build the most recent Emacs master branch developer build -- aka Emacs Trunk -- for MS-Windows.

I found an old blog and went through the procedure, only to be met with an error message telling me that particular method was no longer supported.  The error message referred me to read:  .../emacs/nt/INSTALL.  Well, that is all fine and dandy if the infrastructure for building Emacs has already been installed/configured.

It sure would be handy if there were a step 1, 2, 3 that describes what tools are needed and how to go about installing/configuring them with a specific eye towards building Emacs on MS-Windows.

In the event that anyone would like to prepare a detailed write-up, please feel free to post an answer.  If not, I will write one up myself once I figure out how to do it.  I was met with additional road-blocks and have submitted a bug report in the interim -- I do not yet know whether it is me, or perhaps a bug:  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21582

I think more people would be inclined to build their own Emacs if there were a "cheat-sheet" that could be used by beginning programmers or hobbyists such as myself (who are not programmers by trade).


texts:
I am on a fresh install of emacs 26.3, and I have the following in my init.el:

(require 'package)
(add-to-list 'package-archives
             '("melpa", "http://melpa.org/packages/") t)
(package-initialize)

When I go to refresh the package list (M-x package-refresh-contents) I encounter the following error:

  string-match("\\`https?:" ((\, "http://melpa.org/packages/")) nil)
  package--download-one-archive(("melpa" (\, "http://melpa.org/packages/")) "archive-contents" t)
  package--download-and-read-archives(t)
  package-refresh-contents(t)
  package-menu-refresh()
  package-list-packages(nil)
  funcall-interactively(package-list-packages nil)
  call-interactively(package-list-packages record nil)
  command-execute(package-list-packages record)
  execute-extended-command(nil "package-list-packages" "package-lis")
  funcall-interactively(execute-extended-command nil "package-list-packages" "package-lis")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

What is happening and why doesn't this work? I have seen some chatter on related issues that

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

before (package-initialize) should resolve this issue, but it doesn't.


texts: How to evaluate a symbol in a lambda function when defining it?

texts:
For example,

(lambda () (message "%s" x)))

But I would like x to be evaluated -- the lambda function should always use that value, instead of the current value of x. How should I do it?

Preferably lexical-binding is not required.


texts: How to view files ordered by extension in dired?

texts: Instead of viewing dired buffers with files sorted by name, I want to view it with directories at the top followed by files grouped by extension (and then filename). Is there any package to install to do that? How do I set up my config?


texts: How to use separate versions of a language/runtime with two separate eshells?

texts:
I have two eshell buffers: esh1 and esh2.

In esh1, I want to use a particular Node version, say 6.0.0. In esh2, I want to use a different Node version, say 8.0.0.

Using a node version manager called 'n', I check the versions in both eshells. They're both 6.0.0.

So I go to esh2 and n 8.0.0 which will change the working version of node. I check to ensure it's been updated.

However, when I go to esh1, it now also has version 8.0.0.

So it appears that eshell saves variables across all instances. This seems to support that: https://www.gnu.org/software/emacs/manual/html_node/eshell/Variables.html

Are there any work arounds for this?

Note 1: I haven't tried other version managers, like nvm, or rvm (for ruby), because I've had issues using them with eshell, but my guess is that I'd see the same problem. If I can get them working with eshell, I'll edit to confirm.

Note 2: I'm not interested in solutions like use "shell", "ansi-term", or "iterm".


texts: How to use doom emacs as a golang ide quickly?

texts:
I installed the newest doom emacs on macOS. Also configed language packages as
$ emacs ~/.doom.d/init.el
:lang
(go +lsp)
:tools
lsp

$ ~/.emacs.d/bin/doom sync

When I open a .go file, the code became highlight. But after save the file, the code can't been formated automatically.
I have installed gofmt and goimports. How to set emacs to use them?
I read this document: lang/go module.
It seems it can do it: Auto-formatting on save (gofmt). Maybe because of environment path? So how to call system path from emacs?
My GOPATH is ~/go, it set in ~/.zshrc. When I open shell via M+x, something is different from terminal. How to import .zshrc configuration completely?


texts:
Babel lets you include code blocks of different programming languages inside an Org-mode document, which can be printed and executed. Is there something similar for other modes as well?
For example, I would like to include code blocks inside TeX-mode.


texts: Create new major mode from cc-mode that allows comments with two dashes

texts:
It is possible and relatively easy to create a new major mode, deriving from c-mode, and just add two dashes '--' to work as comments too?
I have checked many resources, but couldn't find anything similar. I tried some approaches, but I'm pretty novice with emacs-lisp programming, and c-mode seemed overwhelming for my knowledge.

Any hints will be appreciated.


texts: Suppress the message (LSP :: not indexed)

texts:
I couldn't find an option to suppress this message on unindexed files.

In my repo I have C++ files that I dont want to index and this message keeps showing up when moving the cursor between code lines.

Is there a way to suppress it? Or view it once when visiting an unindexed file instead of continuously?


texts: Why does Emacs swap Backspace and Delete on this one machine?

texts:
One of my key bindings is not working on one particular machine and I don't understand why.

On Ubuntu 14.04, with the emacs24 package version 24.3+1-2ubuntu1, I start emacs -Q (under X) and run

(global-set-key [(meta backspace)] 'undo)

then press Ctrl+H, c, Alt+BackSpace.

On machine 1, I see as expected that

<M-backspace> runs the command undo

On machine 2, I see

M-DEL (translated from <M-backspace>) runs the command backward-kill-word

The machines are running the same distribution and should be configured pretty much identically. The Emacs packages are the same, yet they react differently even under emacs -Q.

After a bit of investigation, it turns out that the culprit is input-decode-map, which on machine 2 contains

(keymap
 (27 keymap
     (C-backspace .
          [27 C-delete])
     (C-delete .
           [27 C-backspace]))
 (C-M-backspace .
        [C-M-delete])
 (C-M-delete .
         [C-M-backspace])
 (M-backspace .
          [M-delete])
 (M-delete .
       [M-backspace]))

On machine 1, the keymap contains the same keys, but they're all bound to nil.

Why does input-decode-map exchange BackSpace and Delete on machine 2?
How do I fix this? I can obviously remove the entries, but there may be terminals where it's warranted; how do I change input-decode-map on X11 only (keeping in mind that I do sometimes open terminal and X11 frames in the same instance, so testing window-system in .emacs isn't good enough)?


texts: Multiplatform solution to view pdf files in Emacs

texts:
I'm searching for solution for viewing .pdf files in Emacs on both Linux and Windows platform.

Here is list of my requirements:

Outline (view, use to navigate)
Follow links
Search text

Basically I'm searching for alternative to pdf-tools since pdf-tools does not support windows platform atm.

Functionality I'm searching for can be seen in following gif

and in this video which show even more functionality than I desire.


texts:
I have followed these instruction to create a stack of visited position across buffers:

(defvar jedi:goto-stack '())
(defun jedi:jump-to-definition ()
  (interactive)
  (add-to-list 'jedi:goto-stack
               (list (buffer-name) (point)))
  (jedi:goto-definition))
(defun jedi:jump-back ()
  (interactive)
  (let ((p (pop jedi:goto-stack)))
    (if p (progn
            (switch-to-buffer (nth 0 p))
            (goto-char (nth 1 p))))))

This worked well in most case, except when you visited files with the same name under different directories.

Example, you have two files ~/a/test.py and ~/b/test.py. When you first visit ~/a/test.py, the emacs buffer name will be test.py. Now, I used jedi:jump-to-definition function above to go to ~/b/test.py.

As it intended to do, before switching to ~/b/test.py, it push current buffer name and position to stack jedi:goto-stack as (test.py (point)).

But emacs saw two files have the same name, they uniquify them, make their buffer name to test.py<a> and test.py<b>. Now, I can't use jedi:jump-back to go to previous buffer ~/a/test.py, because the stack only contains (test.py (point)).

Can I check when did emacs uniquify the buffer name, and push the new uniquify name to my stack instead of the old one?


texts:
I have a basic ordered list in org mode. After exporting to HTML it takes the default class that org mode assigned:

For some lists, however, I'm trying to assign a custom class (like "special_list", for example).

The org mode documentation says you could add an attribute in this fashion:

#+ATTR_HTML: :class special_list
1. First point
2. Second point

But that doesn't seem to work in this case. Do I have the syntax wrong, or is there a different method for applying custom classes?


texts: Is it possible to automatically capitalise i when writing in org-mode?  I have to manually search all i and replaced it with I, before exporting to PDF. I want to do this only for the English word I, not occurrences of the letter i that may appear within words.


texts:
I'm getting weird results on exporting Org files to LaTeX.  The following Org code produces blank pages and the resulting PDF terminates before the fifth heading and subheadings are printed:

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

I see nothing unusual in the generated LaTeX code.  Any assistance greatly appreciated.  Will be glad to post further info, but not sure what else I should post.


texts:
(format-time-string "%p") is empty in my Emacs. How I can format date in AM/PM format?

That answer second part of Show time in different time zones

UPDATE

(length (format-time-string "%p"))  ; is 0
(getenv "LC_TIME")                  ; is "en_DK.utf8"

My default preferences (in .emacs):

(setq display-time-24hr-format t)
(setq display-time-day-and-date nil)


texts:
I currently use emacs to write and compile LaTeX files using the key combo: C-c C-f.  Now this is all well and good, but now I'm working on a much bigger project that is divided into many chapters.  My main file includes these chapters using \include{chp1} for example, and so I have to go back to the main file to use C-c C-f to compile everything.

So here's my question: When I am editing chp1.tex, is there any way to turn OFF the automatic recognition of LaTeX mode so that if I mistakenly hit C-c C-f, it doesn't freak out and spam me with pages and pages of LaTeX error messages?  I'd like it to just tell me when I type C-c C-f in chp1.tex, "you stupid idiot, this is not the main file," rather than try to compile chp1 by itself.


texts: Methods for examining large/complicated lisp objects

texts:
I've been working with some org export engine code which passes around some rather large and complex list objects.  It's rather tedious to explore an object by reading through a long word-wrapped printed representation of an object or iteratively writing and evaluating accessors in the scratch buffer.  I and am wondering if there are any good methods for interactively examining values.

Take for example: many IDE's that present object values in an interactive tree view which permits incrementally expanding keys/values.  The object is persistently shown on the screen and can be examined without much concern about the value types being viewed.  A random screenshot of Chrome developer tools as illustration:

Other tools present values as navigable popovers (functionally very similar).  A random screenshot from Visual Studio:

Is there anything similar for emacs lisp?  Perhaps something built into edebug or provided by another package?  Or is this just waiting to be developed?

Note: I discovered pp and pp+ shortly after posting this question.  The formatting is incredibly helpful in visually navigating object structure.  It saves needing to modify print-length and print-depth to extreme values and formatting the output in a separate buffer.


texts: How to create a small bibtex file from a bigger one?

texts:
Q: how do I create a stripped-down bibtex file based on the
citations used in a given paper?

I have a single, master bibtex file that contains thousands of
entries.  For most papers, I only ever use a few dozen of those
entries.

When I submit the final version of a paper to a journal for
publication, I need to give them a bibtex file as well.  Rather
than give them my behemoth bibtex file, I would prefer to give
them a stripped down version that only includes the entries I used
in the paper.

How would I automate the process of creating the stripped-down
bibtex file from the master file?

(I'm using AUCTeX, and would prefer not to get org-mode involved
in the process if possible.)


texts:
I'm interested in learning how the term "yank" got its name. I'm also interested in why Emacs "yank" differs from vi/vim "yank".

See also: dual question about Vi, also on Unix & Linux;


texts:
(global-set-key [?\S- ] 'set-mark-command)

(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)

What's the differences and when to use what?


texts:
What I'm trying to achieve
I'm trying to create a popup that runs an elisp funtion I've written which searches my library directory for pdfs, gets the user to choose an option (using completing read) and opens the selected pdf.
What I've done
Because I want it available as a keybinding in my desktop env, I'm running it through a wrapper using emacsclient. I'm calling:
emacsclient --eval "(mwe-pdf-lookup-and-quit)" -a ""

Which points to the function:
(defun mwe-pdf-lookup-and-quit ()
  (make-frame '((width . 80) (height . 25)
                (minibuffer . only)
                (name . "lookup")))
  (sleep-for 0.01)
  (select-frame-by-name "lookup")
  (select-frame-set-input-focus (selected-frame))
  (message (completing-read ; This is where my pdf search function goes
            "Choose: "
            '("Option 1" "Option 2")))
  (delete-frame))

The problem
Works perfectly if I choose a file. The pdf is opened and the frame is deleted. The problem is, if I decide I don't want to open a file anymore and press C-g, the frame displays "Quit emacsclient request" and hangs around. I would like to know how I can delete the minibuffer frame instead.


texts: In dired buffers, place point on the most important file of that directory

texts:
90% of the time I visit a directory in Emacs, the first thing I do is
move point to a specific file and open it. A lot of times, the file I
need to open is very predictable. For instance:

If there are .tex files in this directory, I usually go straight to master.tex.
At the root of Android projects, it's commonly AndroidManifest.xml.
In a directory where I develop an emacs package, it's almost always
the package's main source file. That's usually, but not always, the
only .el file in this directory.

Is there a way I can have dired automatically place point on these
  files when I open these directories?

This would offer a lot of convenience (as I could open them by just
hitting RET), but would still give the flexibility of
visiting other files.


texts: how to prevent debugger from taking focus when you evalute lisp expresison with errors

texts:
How to reproduce:

write some faulty elisp code
press C-x C-e for eval-last-sexp
the debugger will appear  (*backtrace* window) and take the focus of the cursor.

I'd like the focus to remain with the original window so. How can I do that?


texts:
I have a very bad formatted code like below.
Is there a way to make this code more legible?

(add-hook 'LaTeX-mode-hook           '(lambda ()
             (setq ispell-tex-skip-alists
(list                     (append
                     (car ispell-tex-skip-alists) ;tell ispell to ignore content of this:
                     '(("[^\\]\\$" . "[^\\]\\$")))                    (cadr ispell-tex-skip-alists))) ))


texts: how to produce a dired buffer listing all untracked files?

texts:
git status tells me names of files that are currently untracked.  How can I get a dired buffer containing those files? e.g. if I run the command git ls-files --others --exclude-standard, I'd like all of those files in a dired buffer?

Something like M-x find-dired would work, except I don't want the output of find, I need the output of the git command above.


texts: Enlarge font size of function names in source code like Source Insight

texts: Source Insight can show function names in a larger font. Can Emacs display function names with a larger font and different color?


texts: How do I specify a custom face with font-lock-defaults?

texts:
If I define font lock keywords using existing faces, I can highlight the string 'foo'.

(defconst my-mode-font-lock-keywords
  (list
   (cons "foo" 'font-lock-type-face)))

(define-derived-mode my-mode fundamental-mode "My mode"
  "A demo mode."
  (set (make-local-variable 'font-lock-defaults) '(my-mode-font-lock-keywords)))

This highlights correctly:

However, if I define my own face:

(defface my-mode-foo-face
  '((t :inherit font-lock-preprocessor-face))
  "Face for highlighting 'foo'.")

(defconst my-mode-font-lock-keywords
  (list
   (cons "foo" 'my-mode-foo-face)))

(define-derived-mode my-mode fundamental-mode "My mode"
  "A demo mode."
  (set (make-local-variable 'font-lock-defaults) '(my-mode-font-lock-keywords)))

No highlighting is applied:

How can I use font-lock-defaults with a face I've defined myself?


texts: How to reuse last input in command with a prompt?

texts: Some existing functions have ability to remember last input, which you can use in the next command call - for example, replace-string will suggest the last replacement by default, while isearch will look for the thing you searched for last, after pressing the combination once again. How can I achieve the same effect as in replace-string?


texts: Non-Indentation of only C++ comments in C++ mode

texts:
How can I configure my ~/.emacs so as to get the following effect?  In C++ mode, I want C++ comments (but not C-style comments), to always be unindented, i.e., the double slashes should always be first in a line, not preceded by whitespace.  By default, the Emacs C++ mode will indent C++ comments in the same way as it would any single-line statement.  I.e., I want code to look like:

int main() {
        /* x is the number of foos */
        int x = 1;
//      int x = 2;
        if (x == y) {
                 /* a is the number of bars */
                 int a = x;
//               int a = 2 * x;
        }
}

Note that C-style comments should still be indented normally.

Background:  I have a C++ codebase in which all "normal" comments are in C-style, and C++ comments are only used to comment out code.  This means that I can search for the string "//" within the cleanup to remove all such comments before I commit my code to SVN.  When commenting out code using C++ comments, the default behavior of Emacs makes it harder to see the old (commented-out) and new code side by side.  I.e., Emacs would give this:

int main() {
        /* x is the number of foos */
        int x = 1;
        //      int x = 2;
        if (x == y) {
                 /* a is the number of bars */
                 int a = x;
                 //               int a = 2 * x;
        }
}

Note also that C++ comments that follow code on a line should not be affected.


texts: How do you get the LOGBOOK information from the current heading at point?

texts:
Given a TODO that looks like this:

*** DONE put into spacemacs file
    CLOSED: [2018-08-04 Sat 21:18]
   :LOGBOOK:
    CLOCK: [2018-08-04 Sat 21:16]--[2018-08-04 Sat 12:18] =>  0:02
   :END:

What function will get me the parts in CLOCK: [2018-08-04 Sat 21:16]--[2018-08-04 Sat 12:18] =>  0:02?

Preferably it would be in plist format like the closed timestamp org-element-at-point gives back of:

(timestamp (:type inactive :raw-value "[2018-08-04 Sat 21:18]" :year-start 2018 :month-start 8 :day-start 4 :hour-start 21 :minute-start 18 :year-end 2018 :month-end 8 :day-end 4 :hour-end 21 :minute-end 18 :begin 46 :end 68 :post-blank 0)

Note org-element-at-point doesn't give back logbook information:

(headline (:raw-value "put into spacemacs file" :begin 1 :end 157 :pre-blank 0 :contents-begin 34 :contents-end 157 :level 3 :priority nil :tags nil :todo-keyword #("DONE" 0 4 (fontified t face org-done)) :todo-type done :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :closed (timestamp (:type inactive :raw-value "[2018-08-04 Sat 21:18]" :year-start 2018 :month-start 8 :day-start 4 :hour-start 21 :minute-start 18 :year-end 2018 :month-end 8 :day-end 4 :hour-end 21 :minute-end 18 :begin 46 :end 68 :post-blank 0)) :title "put into spacemacs file"))

What function will get me the parts in CLOCK: [2018-08-04 Sat 21:16]--[2018-08-04 Sat 12:18] =>  0:02?


texts: Problem with save-current-buffer and find-file

texts:
I have a list of files that I want to successively visit with find-file and then return to the first buffer. I thought that save-current-buffer would help me to achieve this. However, with the following code, the cursor ends up in one of the buffers opened by find-file, not in the buffer where save-current-buffer had been executed:

(save-current-buffer
    (dolist (file org-agenda-files)
        (find-file file)
        ;; do something with file
        ))

How can I return to the first buffer after find-file?


texts: Pull from git before applying org-capture?

texts:
I'm using org-capture to take project-specific notes by having a notes file in each of several git repositories.  Looking forward, however, I can see danger here: if I'm working on project (1) and I think to drop a note in project (2), I'll probably forget to commit it; doing this on multiple computers and syncing via github just begs for merge conflicts.
Does anyone know a way to solve at least part of this problem by having org-capture automatically pull from remote before it starts a note?  I thought of trying to just use advice to do it, but there's no obvious way to do that given that the specific repository isn't selected until after org-capture is run...


texts:
My Emacs usually works well, but sometimes it freezes, to be more specific:

It only freezes after pressing ESC.
When the freeze begins, it will always freeze after pressing ESC: I kill Emacs, restart it, press ESC, then it freeze again. Unless I restart the the computer. After restarting, Emacs goes to normal again.
I can do nothing to bring it back to normal, including C-g, pkill -USR2 emacs, even emacsclient -nw in the terminal freezes.
Emacs -Q still freezes after pressing ESC.

Is there any way to find out the reason and solve it?
I'm using archlinux with GNU Emacs 27.1, this is uname -a:
Linux archlinux 4.19.18-1-lts #1 SMP Sat Jan 26 13:20:43 CET 2019 x86_64 GNU/Linux


texts:
I find ivy-switch-to-buffer is handy abo-abo/swiper: Ivy

Is it possible to bind the function to C-x b

Additionally, my C-x C-b is bonded to ibuffer

How could rebind it to function 'helm-buffer-list"?


texts: Can magit-git-command use Emacs mini-buffer when prompted?

texts:
In my company we use a Git extension which has command-line interface that requires interaction (answering prompt).  I would like to extend Magit to be able to deal with our extension.  Unlike most of Magit functionality, this has to actually interact with the Git process by collecting users' input (this is company's policy, something to prevent automatic submissions, questionable as it may be, isn't a subject to change).

Ideally, in the future, I'd write a proper extension with a dedicated buffer and, font-faces and key-bindings, but for now, I'd be happy with just the ability to answer yes/no to the prompt.


texts: Dired: File open using external viewers, based on filetype, and without prompting

texts:
When I hit RETURN on a filename in Dired, I'd like Emacs to automatically do one of several things, depending on the file's type:

1 - If it's a text file, I'd like to open the file in a new buffer in Emacs.

2 - If the filetype is listed in a user-configurable list of filetypes and external viewers, open the file in an external viewer associated with that filetype.

3 - If the filetype is not text and not in the above list, return an error saying the file is of an unknown type.

I've found some answers (1, 2) that advise using dired-read-shell-command and either ! or & to open files with external viewers.

The above answers are insufficient for my needs, because:

1 - They require multiple keystrokes (at least ! or & and then RETURN at the prompt), while I want this done with just a single keystroke, without any prompting.

2 - They won't open text files in Emacs, but will instead try to use external viewers for everything.  I want text files opened in Emacs.

3 - They dispatch based on filename extensions, while I want to dispatch based on filetype (ie. as a result of using either the "file" or "mimetype" command on linux)

4 - They don't error-out if the filetype is not found in the list of known filetypes.


texts: Tie a minor-mode to a particular major mode

texts:
I'm writing an extension to a major mode (coq-mode) that adds extra features, plus a few keybindings.

To makes it easy to disable or redefine these keybindings, I packaged them in a keymap. That keymap is tied to a myplugin-keybindings-minor-mode minor mode, which gets enabled in coq-mode-hook.

Most of these keybindings do not make sense outside of coq-mode. Yet when I open new buffers from a coq-mode buffer, myplugin-keybindings-minor-mode is enabled in the newly opened buffer.

How do I prevent this from happening? How do I tie my minor mode to coq-mode, so that myplugin-keybindings-minor-mode is never active when coq-mode isn't? Altenatively, which other approach should I use?

EDIT:

The minor mode is enabled by using (add-hook 'coq-mode-hook #'myplugin-initialize), and myplugin-initialize calls (myplugin-keybindings-mode 1).

EDIT2: You can see the problem I'm talking about by opening a diff-mode buffer (C-x f test.diff), and then running M-x shell from it. The shell buffer had the Diff-Auto-Refine mode on, inherited from the diff buffer. This isn't a problem for Diff-Auto-Refine, but it is for myplugin-keybindings


texts: If I have an [[Org Mode Link]] and then make that line a # Comment [[Org Mode Link]] the fontification changes and I can no longer tell that it is a link. Can this behavior be changed?


texts: Run ssh-add from Emacs and enter a passphrase

texts:
I want to call the ssh-add shell command.
So I invoke M-x shell-command RET, and
in the minibuffer, I type: ssh-add .ssh/id_rsa

The only thing I get is:

ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory^M

How can I make Emacs give me another prompt, so I can type the passphrase ssh-add is waiting for?

This is with Emacs under X11 on Debian.


texts: how to fix flyspell-lazy args-out-of-range error?

texts:
I use flyspell-lazy to improve flyspell performance and it works really well. However, when I open a buffer with a lot of text, I get this error:

Debugger entered--Lisp error: (args-out-of-range #<buffer buffer2> 155 215)
  #<subr buffer-substring-no-properties>(215 155)
  ad-Advice-buffer-substring-no-properties(#<subr buffer-substring-no-properties> 215 155)
  apply(ad-Advice-buffer-substring-no-properties #<subr buffer-substring-no-properties> (215 155))
  buffer-substring-no-properties(215 155)
  flyspell-lazy-check-pending()
  apply(flyspell-lazy-check-pending nil)
  timer-event-handler([t 0 3 0 t flyspell-lazy-check-pending nil idle 0])

Here's another version of the error:

Debugger entered--Lisp error: (args-out-of-range #<buffer 0-why-I-wrote-this-book.txt> 90378 90651)
  buffer-substring-no-properties(90651 90378)
  flyspell-lazy-check-pending()
  apply(flyspell-lazy-check-pending nil)
  timer-event-handler([t 0 3 0 t flyspell-lazy-check-pending nil idle 0])

How can I resolve this error?

As requested, here are my flyspell settings:

(use-package flyspell
:config
'(flyspell-abbrev-p t)
'(flyspell-use-global-abbrev-table-p t)
'(global-flyspell-mode t)

:bind
(:map flyspell-mode-map
("C-." . nil)
)
)

;; flyspell skip source blocks
;; NO spell check for embedded snippets
(defadvice org-mode-flyspell-verify (after org-mode-flyspell-verify-hack activate)
  (let ((rlt ad-return-value)
        (begin-regexp "^[ \t]*#\\+begin_\\(src\\|html\\|latex\\)")
        (end-regexp "^[ \t]*#\\+end_\\(src\\|html\\|latex\\)")
        old-flag
        b e)
    (when ad-return-value
      (save-excursion
        (setq old-flag case-fold-search)
        (setq case-fold-search t)
        (setq b (re-search-backward begin-regexp nil t))
        (if b (setq e (re-search-forward end-regexp nil t)))
        (setq case-fold-search old-flag))
      (if (and b e (< (point) e)) (setq rlt nil)))
    (setq ad-return-value rlt)))

(add-hook 'org-mode-hook (lambda () (flyspell-lazy-mode 1)))


texts: Why is `gnus-group-prepared-hook` never called?

texts:
I'm wondering why this hook never works:

(add-hook 'gnus-group-prepared-hook 'gnus-group-list-all-groups)

Description of the hook:

  is called as the very last thing after the group buffer has been generated. It may be used to move point around, for instance.

I've also tried gnus-group-mode-hook (specified function is called, but no effect) and gnus-group-prepare-hook (never called).

Expected behavior: when I start Gnus via M-x gnus, it should list all groups immediately.


texts: How do I write a Flycheck predicate that checks for the checkers config file

texts:
Suppose I have the following Flycheck checker:
(flycheck-def-config-file-var flycheck-jscs
                              javascript-jscs
                              ".jscs"
                              :safe #'stringp)

(flycheck-define-checker javascript-jscs
                         "A jscs code style checker."
                         :command ("jscs" "--reporter" "checkstyle"
                                   (config-file "--config" flycheck-jscs) source)
                         :error-parser flycheck-parse-checkstyle
                         :modes (js-mode js2-mode js3-mode)
                         :next-checkers (javascript-jshint))

(provide 'flycheck-jscs)

How do I add a :predicate that tells flycheck to disable the checker if flycheck-jscs is nil?
I only manage to get this message regardless what code I try with:

Error while checking syntax automatically:
(invalid-function (quote (not (not (quote flycheck-jscs)))))


texts: How to change line-number gutter width using display-line-numbers mode?

texts:
I am using (global-display-line-numbers-mode 1) in my init.el file and everything is working as expected. The only problem is that I find the gutter width to be too wide and would prefer it to match the size that's used when using (linum-mode 1).

I have tried running (setq left-margin-width 10) in my current buffer and it doesn't change anything.

Here is a screen shot of what I mean with linum mode on the left and display-line-numbers-mode on the right:


texts:
I'm new to the LaTeX metre package, but am hoping to use it to create a poetry handout. Right now, it is generating extra symbols when I export from org-mode.

#+LaTeX_HEADER: \usepackage[en]{metre}
\metra{\m\b}

Produces:

The last two symbols there are the ones I asked for. How do I eliminate the four extraneous other symbols from this output?


texts: Elisp: Added one key-binding to dired-mode and lost basic dired functionality

texts:
I wanted an alternative to the awful C-^ shortcut for moving up one directory so I added the following to init file:

 (defun dc/dired-mode-keys ()
   "User defined keys for dired mode."
   (interactive)
   (local-set-key (kbd "s-m" 'dired-up-directory)))
 (add-hook 'dired-mode-hook 'dc/dired-mode-keys)

However, when I open Emacs with this code enabled (i.e., uncommented in the init file), I lose basic dired functionality.  For example, when I press a to open a directory (in the same buffer), I get the following error in the mini-buffer.

Wrong number of arguments: (1 . 1), 2

I've confirmed that s-m is not a native key-binding in dired-mode (I believe very few if any super key combos are natively bound), and I'm pretty sure my code doesn't unbind any of the native key-bindings in dired-mode.

What am I doing wrong in the function above?


texts: C-g has stopped breaking out of commands like `C-x C-f` and `M-x` in graphical emacs-25

texts:
I have always used C-g (ie keyboard-quit) to break out of commands like M-x and C-x C-f.
At some point not too long ago this stopped working.
All that happens is that Quit flashes in the minibuffer but I still have the previous command waiting for input there.
I now have to do Esc Esc Esc (keyboard-escape-quit) or C-] (abort-recursive-edit) to break out of these minibuffer command.

Has the way keyboard-quit works changed?
Or was C-g bound to a different function in past versions?
It happens even when I start with emacs -Q so it should not be a problem of my configuration.

I am using graphical emacs-25.1.1 on Ubuntu-MATE 17.04.

update

I have found that C-g still works as expected when running emacs in the console, ie emacs -nw using the same emacs-25.1.1 executable as below that does not work in graphical mode.

Furthermore C-h k C-g brings up help for keyboard-quit in the console but causes a Quit message to appear in the minibuffer (without breaking out of the C-h kcommand) in graphical mode. However, C-h f keyboard-quit brings up the the help page which does say that it is bound to C-g


texts:
How do I set flycheck-compile to run go-build on save?

I can't find documentation on how to run flycheck-compile with go-build on save.


texts: How to redefine the allout prefix keybinding

texts:
The allout mode document says,

  We recommend customizing allout-command-prefix to use just \C-c as
  the command prefix, if the allout bindings don't conflict with any
  personal bindings you have on \C-c.

I don't like to customize the variable, but like to configure it instead (I think \C-c\C-c is a better option). How can I do that?

UPDATE:

I tried the suggested solution like the following in my init, and it works great.

(defun my-allout-mode-hook ()
      (setq allout-command-prefix (kbd "C-c C-c"))
      )

    (add-hook 'allout-mode-hook 'my-allout-mode-hook)

Another question, how to enable the allout minor mode on Emacs starts for all modes?

Thanks


texts: What are the benefits of using indirect buffers? Under what circumstances are they useful?


texts:
Is there a way to remove occurrences in Occur mode?
In particular, this piece of functionality would allow you to remove occurrences in case you are interested in editing only some out of all occurrences in Occur mode.

Example: say I have this piece of code:

import os
import time

print("Just an example")

john.age = 44
anna.age = 55
print("Something")
bob.age = 83

If I run occur searching for "age", I get:

3 matches for "age" in buffer: untitled
      6:john.age = 44
      7:anna.age = 55
      9:bob.age = 83

And after that I would like to have a function that allows me to, with the cursor in the desired line, remove that occurrence from the buffer so that any following edit will not have any effect into the removed occurrences.
In the given example, if I did not want to edit line 7, I could run the desired function to get the occur buffer in the following new state:

3 matches for "age" in buffer: untitled
      6:john.age = 44
      9:bob.age = 83

I know that it is possible to use Narrowing commands inside an occur buffer, but that would not cover the case where my lines of interest are scattered around other occurrences and it would also not be as simple as selecting the lines I do not want to mess with. Also, having this functionality would save time from having to write complex regular expressions even in the case where we could get the specific occurrences we are interested in from a single search.


texts:
When I'm composing a message in message-mode I sometimes want to remove a recipient from a long list of recipients on the To: line.  It seems that there is no semantic kill command that would delete a complete recipient.

I could zap to the next delimiter, I suppose, but the different formats available for recipients and their display names makes this a lot harder.  When on a To:, Cc: or Bcc: line, I really don't need to be able to delete words or sentences or s-expressions, I just need to be able to remove a recipient as a syntactic unit.

How can I easily augment kill-sexp to remove a recipient (i.e. name and email address in the various common formats) when I'm on a recipient line?


texts: Syntax highlighting is breaking in long bibtex files (spacemacs bibtex layer)

texts:
So I have a long papers.bib bibtex file that I edit with emacs (spacemacs bibtex layer), but the syntax highlighting only ever goes about halfway down. Here it is at about line 790:

Other times this happens elsewhere: line 10,000, line 900, etc. At first I thought this happens because of some incorrect syntax in the Bibtex, but I can't see any errors, actually. What's going on here, and how can I get it to syntax highlight the whole file?